This is a SvelteKit template project with Lucia auth Email and password example with 2FA and WebAuthn already implemented, ready to use and extend.
It uses nodemailer for sending emails.
I simply followed lucia auth's instructions. I'm definitely not an expert on authorization or anything like that. I just thought it might make life easier for some people.
Create a .env file. Generate a 128 bit (16 byte) string, base64 encode it, and set it as ENCRYPTION_KEY.
ENCRYPTION_KEY="L9pmqRJnO1ZJSQ2svbHuBA=="
You can use OpenSSL to quickly generate a secure key.
openssl rand --base64 16
"localgost")."http://localhost:5173").Setup your SMTP server in the transporter.ts file. You can use Gmail. Insert your gmail as GMAIL_EMAIL and an "app password" as GMAIL_PASSWORD in your env file.
Uncomment and fill in / rewrite the informations for the email-verification process in the email-verification.ts file and password-reset process in the password-reset.ts file.
This project uses Drizzle ORM.
npm run db:push to update your database schemanpm run db:push to update your database schemaOnce you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
To create a production version of your app:
npm run build
You can preview the production build with npm run preview.
To deploy your app, you may need to install an adapter for your target environment.