Remult Adapter
Resources
Setup
Installation
npm install remult @auth/remult-adapter
Adapter Setup
./auth.ts
import NextAuth from "next-auth"
import { JsonFileDataProvider } from "remult/server"
import { RemultAdapter } from "@auth/remult-adapter"
// any remult data provider
// postgres, mysql, mongodb, sqlite, mssql, oracle, json files, in memory...
const dataProvider = new JsonFileDataProvider("db")
const { adapter } = RemultAdapter({ dataProvider })
export const { handlers, auth, signIn, signOut } = NextAuth({
adapter,
providers: [],
})
Using your own Entities
If you want to add some fields in some entities, you can override default ones.
./src/auth.ts
import { SvelteKitAuth } from "@auth/sveltekit"
import { JsonFileDataProvider } from "remult/server"
import { RemultAdapter } from "@auth/remult-adapter"
import { User } from "../src/entities"
export class AppUser extends User {
@Fields.string()
jobTitle = ""
}
const dataProvider = new JsonFileDataProvider("db")
const { adapter } = RemultAdapter({
dataProvider,
customEntities: {
User: AppUser,
// Account: ...
// Session: ...
// Authenticator: ...
},
})
export const { handle, signIn, signOut } = SvelteKitAuth({
adapter,
providers: [],
})
Using remult.user
in your app
You can see a full example here.