This is a pretty far-developed starting point. Authentication has been intialized with Better-Auth, a database has been setup with Prisma, and Google + email logins have been enabled, as well as Google + Email registration.
24 lines
732 B
TypeScript
24 lines
732 B
TypeScript
import { betterAuth } from "better-auth";
|
|
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
import { prisma } from "$lib/db";
|
|
import { sveltekitCookies } from "better-auth/svelte-kit";
|
|
import { getRequestEvent } from "$app/server";
|
|
|
|
|
|
export const auth = betterAuth({
|
|
baseURL: process.env.BETTER_AUTH_URL,
|
|
database: prismaAdapter(prisma, {
|
|
provider: "postgresql",
|
|
}),
|
|
emailAndPassword: {
|
|
enabled: true,
|
|
},
|
|
socialProviders: {
|
|
google: {
|
|
prompt: "select_account",
|
|
clientId: process.env.GOOGLE_CLIENT_ID as string,
|
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
|
|
}
|
|
},
|
|
plugins: [sveltekitCookies(getRequestEvent)],
|
|
}) |