From d97dcc88381d16c5f471896e49071ea6eec1b456 Mon Sep 17 00:00:00 2001 From: valhize Date: Thu, 21 May 2026 04:28:17 +0700 Subject: [PATCH] feat: finish Better Auth config --- app/lib/auth-client.ts | 5 +++++ app/routes/api.auth.$.ts | 10 ++++++++++ lib/auth.ts | 3 +++ 3 files changed, 18 insertions(+) create mode 100644 app/lib/auth-client.ts create mode 100644 app/routes/api.auth.$.ts diff --git a/app/lib/auth-client.ts b/app/lib/auth-client.ts new file mode 100644 index 0000000..ecae7d3 --- /dev/null +++ b/app/lib/auth-client.ts @@ -0,0 +1,5 @@ +import { createAuthClient } from "better-auth/react"; + +export const authClient = createAuthClient({ + baseURL: "http://localhost:3000", +}); diff --git a/app/routes/api.auth.$.ts b/app/routes/api.auth.$.ts new file mode 100644 index 0000000..52b8fa2 --- /dev/null +++ b/app/routes/api.auth.$.ts @@ -0,0 +1,10 @@ +import { auth } from "../../lib/auth"; +import type { LoaderFunctionArgs, ActionFunctionArgs } from "react-router"; + +export async function loader({ request }: LoaderFunctionArgs) { + return auth.handler(request); +} + +export async function action({ request }: ActionFunctionArgs) { + return auth.handler(request); +} diff --git a/lib/auth.ts b/lib/auth.ts index 1c6edfd..6e6f864 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -3,4 +3,7 @@ import Database from "better-sqlite3"; export const auth = betterAuth({ database: new Database("./sqlite.db"), + emailAndPassword: { + enabled: true, + }, });