This Quickstart is currently in Beta. We’d love to hear your feedback!
AI Prompt
AI Prompt
Using AI to integrate Auth0? Add this prompt to Cursor, Windsurf, Copilot, Claude Code or your favourite AI-powered IDE to speed up development.
Get Started
This quickstart demonstrates how to add Auth0 authentication to a Svelte application. You’ll build a secure single-page app with login, logout, and user profile features using the Auth0 SPA JS SDK.1
Create a new project
Create a new Svelte project for this QuickstartOpen the project
2
Install the Auth0 SPA SDK
3
Setup your Auth0 App
Next up, you need to create a new app on your Auth0 tenant and add the environment variables to your project.You have three options to set up your Auth0 app: use the Quick Setup tool (recommended), run a CLI command, or configure manually via the Dashboard:
- Quick Setup (recommended)
- CLI
- Dashboard
Create an Auth0 App and copy the pre-filled
.env file with the right configuration values.4
Create the Auth0 store
Create the store fileAdd the following code to manage authentication state
src/lib/stores/auth.ts
5
Create Login, Logout and Profile Components
Create component filesAnd add the following code snippets
6
Run your app
CheckpointYou should now have a fully functional Auth0 login page running on your localhost
Troubleshooting
Login Not Working
Login Not Working
If clicking the login button does nothing:
- Open browser DevTools (F12) and check the Console tab
- Verify
.envfile has real Auth0 credentials - Check that Auth0 application has correct callback URLs configured
- Ensure
VITE_AUTH0_DOMAINis just the domain (e.g.,tenant.auth0.com) withouthttps://
Authentication Errors
Authentication Errors
“Callback URL mismatch”:
- Go to Auth0 Dashboard → Applications → Your App → Settings
- Add
http://localhost:5173to Allowed Callback URLs, Allowed Logout URLs, and Allowed Web Origins - Click “Save Changes”
- Clear browser cache and cookies
- Try in an incognito/private window
Dev Server Issues
Dev Server Issues
If
npm run dev fails:- Run
npm run checkto see TypeScript errors - Verify all files were created correctly
- Check that all dependencies are installed:
npm install