Configuration
Database Adapter
Configure an Auth.js database adapter.
Example using Prisma
// in src/hooks.server.js
import { SvelteKitAuth } from '@airbadge/sveltekit'
import { PrismaClient } from '@prisma/client'
import { PrismaAdapter } from '@auth/prisma-adapter'
const db = new PrismaClient()
export const handle = SvelteKitAuth({
adapter: PrismaAdapter(db)
})
Note: This package requires some extra fields in the database. See Database Guide for more information on updating your schema.
Authentication Providers
AirBadge supports all Auth.js authentication providers.
Example
// in src/hooks.server.js
import { SvelteKitAuth } from '@airbadge/sveltekit'
import GitHub from '@auth/sveltekit/providers/github'
export const { handle } = SvelteKitAuth({
providers: [ GitHub ]
})
Pages
All page options from Auth.js are supported. With some additional options:
Additional options
Attribute | Description |
---|---|
checkout.success | Page user will be sent to after a checkout succeeds. |
checkout.cancel | Page user will be sent to after a checkout is canceled. |
portalReturn | Page user will be sent to when returning from billing portal. |
Example
// in src/hooks.server.js
import { SvelteKitAuth } from '@airbadge/sveltekit'
export const handle = SvelteKitAuth({
pages: {
checkout: {
success: '/dashboard',
cancel: '/pricing'
},
portalReturn: '/dashboard'
}
})
Callbacks
All callback options from Auth.js are supported.
Example
callbacks: {
async signIn({ user, account, profile, email, credentials }) {
return true
},
async redirect({ url, baseUrl }) {
return baseUrl
},
async session({ session, user, token }) {
return session
},
async jwt({ token, user, account, profile, isNewUser }) {
return token
}
}