Auth.js
Setup Launch Leopard with Auth.js
Auth.js (previously NextAuth.js) is a authentication library that is framework and runtime agnostic.
Check the Auth.js documentation for SvelteKit for more information.
Note that Auth.js and its adapter and framework API’s are pre-1.0. They are likely to change.
Setting up the Auth.js boilerplate
By default Launch Leopard uses the email provider (with magic login links) for authentication.
Here is how to set it up:
Update .env file
Update the .env
file with your Postgres database connection string:
PRIVATE_DATABASE_URL=[YOUR POSTGRES CONNECTION STRING]
Run migrations
The database schema has all the tables needed for Auth.js, located in src/lib/server/database/schema.ts
In your terminal, run
to create the database migration files and run the migration with Drizzle Kit
Setup Loops
Make sure you have setup Loops (transcactional + marketing email platform), check the guide here.
sendVerificationRequest
function in hooks.server.ts
for this.Create new Transactional email
Create a new transcactional email in Loops here.
Add a datavariable called verificationUrl
in the email template. That’s where the verification url will be added.
You can customize and style the email template however you like.
Hit “Next” and publish the email template.
Set the transactional id
You should now see a TRANSACTIONAL ID.
Copy the TRANSACTIONAL ID and set it in hooks.server.ts
in the EmailProvder
provider in the body of the fetch
request.
Other auth providers
Auth.js implements many auth providers, like email, Google, Facebook, Twitter, GitHub, and more.
Add the providers to your hooks.server.ts
and signin pages.
See the Auth.js docs for more information how to implement other providers.
Database Adapters
Auth.js also implements many database adapters, like Drizzle, Supabase, Prisma, and more.
By default, Launch Leopard implements the Drizzle adapter.
See the database section for more information.