This repository demonstrates how to integrate Auth0 authentication with a SvelteKit application. Auth0 provides a flexible, secure, and easy-to-use authentication and authorization platform, while SvelteKit offers a powerful framework for building web applications with Svelte.
Before you begin, ensure you have the following installed:
- Node.js and npm/yarn
- Auth0 Account
-
Clone the repository:
git clone https://github.com/arthurjgs/sveltekit-auth0-integration.git
-
Install dependencies:
cd auth0-sveltekit-integration npm install -
Configuration:
-
Copy the
.env.examplefile to.env:cp .env.example .env
-
Update
.envwith your Auth0 credentials and settings.
-
-
Run the application:
npm run dev
This command will start the development server. Open your browser and navigate to
http://localhost:5173to view the application.
-
Create an Auth0 Application:
- Go to the Auth0 Dashboard
- Navigate to Applications and click on "Create Application"
- Choose "Regular Web Application" and provide a name for your application
- Configure the allowed Callback URLs, Logout URLs, and Allowed Web Origins based on your development environment (
http://localhost:5173for local development) - Save your changes
-
Update Auth0 Settings in
.env- Update the
.envfile with your Auth0 Domain, Client ID, and Client Secret obtained from the Auth0 Dashboard.
- Update the
This application provides a simple demonstration of how to integrate Auth0 authentication with SvelteKit. Users can sign up, log in, and log out using Auth0's Universal Login feature. The authentication state is managed without any SDK.
/src: Contains the source code of the SvelteKit application./src/routes/api: Contains the api routes for handling authentication./src/lib/auth: Contains utility functions and Auth0 configuration.
Contributions are welcome! Please feel free to submit pull requests or open issues if you encounter any problems or have suggestions for improvements.
This project is licensed under the MIT License - see the LICENSE file for details.
Note: This README provides a basic overview of setting up Auth0 integration with SvelteKit. For more detailed information, refer to the official documentation of Auth0 and SvelteKit.