### Setup commands Source: https://github.com/devx-op/effectify/blob/master/apps/react-router-example/README.md Install dependencies, generate a local BETTER_AUTH_SECRET, and start the development server. The secret is generated with openssl and should not be committed. ```bash pnpm install export BETTER_AUTH_SECRET="$(openssl rand -base64 32)" pnpm nx run @effectify/react-router-example:dev ``` -------------------------------- ### Run SvelteKit example with pnpm Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Commands to install dependencies and start the development server for the SvelteKit example. Run these in the project root after cloning and setting up the .env file. ```bash pnpm install pnpm dev ``` -------------------------------- ### Run Nuxt Example: pnpm install and pnpm dev Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Commands to install dependencies and start the development server for the Nuxt example. Requires cloning the repo and setting up .env from .env.example first. ```bash pnpm install pnpm dev ``` -------------------------------- ### Install and Run Commands Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Commands to install dependencies and start the development server. After running, open http://localhost:3000 in the browser. ```bash pnpm install pnpm run dev ``` -------------------------------- ### Install winston Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Installs the winston logging library, a prerequisite for the logging service example. ```bash npm install winston ``` -------------------------------- ### Install @better-auth/stripe with bun Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the plugin using bun. Ensure it is installed in both client and server parts if using a separate setup. ```bash bun add @better-auth/stripe ``` -------------------------------- ### Install UI Components Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/getting-started.md Install the pre-built UI components package. ```bash npm install @effectify/react-ui ``` -------------------------------- ### Start development server Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Start the development server with pnpm dev. ```bash pnpm dev ``` -------------------------------- ### Install @dub/better-auth with bun Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the @dub/better-auth plugin using bun. ```bash bun add @dub/better-auth ``` -------------------------------- ### Install and initialize Prisma Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Install Prisma CLI and client, then initialize Prisma in the project. ```bash npm install prisma @prisma/client npx prisma init ``` -------------------------------- ### Create SolidStart Project and Install Packages Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/solid/installation.md Creates a new SolidStart project and installs the required packages. ```bash npm create solid@latest my-app -- --template solid-start cd my-app npm install @effectify/solid-query @tanstack/solid-query effect ``` -------------------------------- ### Install @better-auth/stripe with yarn Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the plugin using yarn. Ensure it is installed in both client and server parts if using a separate setup. ```bash yarn add @better-auth/stripe ``` -------------------------------- ### Prepare ENV files Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Copy the example environment file to create a new .env file for the docs. ```bash cp -n ./docs/.env.example ./docs/.env ``` -------------------------------- ### Install @better-auth/stripe with pnpm Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the plugin using pnpm. Ensure it is installed in both client and server parts if using a separate setup. ```bash pnpm add @better-auth/stripe ``` -------------------------------- ### Install @better-auth/stripe with npm Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the plugin using npm. Ensure it is installed in both client and server parts if using a separate setup. ```bash npm install @better-auth/stripe ``` -------------------------------- ### Build react-router-example Source: https://github.com/devx-op/effectify/blob/master/openspec/changes/archive/2026-08-26-consolidate-react-remix-into-router/apply-progress.md Build the react-router-example project. ```bash pnpm nx run @effectify/react-router-example:build ``` -------------------------------- ### Install @prisma/client (bun) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Prisma client as a runtime dependency using bun. ```bash bun add @prisma/client ``` -------------------------------- ### Example popup component using auth client Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt A quick example of a popup component that imports the auth client. This is a starting point for building the extension UI. ```tsx import { authClient } from "./auth/auth-client" ``` -------------------------------- ### Set and get cookies in hook Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Example of setting and getting cookies using ctx.setCookies, ctx.setSignedCookie, ctx.getCookies, and ctx.getSignedCookies. Shows how to set a signed cookie with a secret and maxAge. ```TypeScript import { createAuthMiddleware } from "better-auth/api"; const hook = createAuthMiddleware(async (ctx) => { ctx.setCookies("my-cookie", "value"); await ctx.setSignedCookie("my-signed-cookie", "value", ctx.context.secret, { maxAge: 1000, }); const cookie = ctx.getCookies("my-cookie"); const signedCookie = await ctx.getSignedCookies("my-signed-cookie"); }); ``` -------------------------------- ### TanStack Start handler for Better Auth Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Use this handler to integrate Better Auth with a TanStack Start server. It defines a server route for /api/auth/$ that handles GET and POST requests. ```ts import { auth } from '~/lib/server/auth' import { createServerFileRoute } from '@tanstack/react-start/server' export const ServerRoute = createServerFileRoute('/api/auth/$').methods({ GET: ({ request }) => { return auth.handler(request) }, POST: ({ request }) => { return auth.handler(request) }, }); ``` -------------------------------- ### Development commands Source: https://github.com/devx-op/effectify/blob/master/apps/react-router-example/README.md Run tests, typecheck, lint, and build for the example app. ```bash pnpm nx run @effectify/react-router-example:test pnpm nx run @effectify/react-router-example:typecheck pnpm nx run @effectify/react-router-example:lint pnpm nx run @effectify/react-router-example:build --skip-nx-cache ``` -------------------------------- ### Install Better Auth with npm, pnpm, yarn, or bun Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install Better Auth using your preferred package manager. The tabs show npm, pnpm, yarn, and bun commands. If you have a separate client and server setup, install Better Auth in both parts of your project. ```bash npm install better-auth ``` ```bash pnpm add better-auth ``` ```bash yarn add better-auth ``` ```bash bun add better-auth ``` -------------------------------- ### Start docs server Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Start the documentation server using the docs package. ```bash pnpm -F docs dev ``` -------------------------------- ### Get an API key Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Server-side example to retrieve API key details by keyId. Throws an APIError on failure. ```TypeScript const key = await auth.api.getApiKey({ body: { keyId: "your_api_key_id_here", }, }); ``` -------------------------------- ### Install PostgreSQL client (npm, pnpm, yarn, bun) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the pg package using your preferred package manager. Choose the command for your package manager. ```bash npm install pg ``` ```bash pnpm add pg ``` ```bash yarn add pg ``` ```bash bun add pg ``` -------------------------------- ### Client plugin setup in auth-client.ts Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Adds the apiKeyClient plugin to the Better Auth client configuration. This is the third step in installation. ```TypeScript import { createAuthClient } from "better-auth/client" import { apiKeyClient } from "better-auth/client/plugins" export const authClient = createAuthClient({ plugins: [ // [!code highlight] apiKeyClient() // [!code highlight] ] // [!code highlight] }) ``` -------------------------------- ### Create client instance (Solid) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Import createAuthClient from 'better-auth/solid' and create a client with the base URL of the auth server. The baseURL is highlighted as the key configuration. ```typescript import { createAuthClient } from "better-auth/solid" export const authClient = createAuthClient({ baseURL: "http://localhost:3000" // The base URL of your auth server // [!code highlight] }) ``` -------------------------------- ### Server plugin setup in auth.ts Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Adds the apiKey plugin to the Better Auth server configuration. This is the first step in installation. ```TypeScript import { betterAuth } from "better-auth" import { apiKey } from "better-auth/plugins" export const auth = betterAuth({ plugins: [ // [!code highlight] apiKey() // [!code highlight] ] // [!code highlight] }) ``` -------------------------------- ### Create Solid client (lib/auth-client.ts) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Import createAuthClient from 'better-auth/solid' and export the client instance. ```ts import { createAuthClient } from "better-auth/solid" export const authClient = createAuthClient() ``` -------------------------------- ### Install Tailwind CSS and Initialize Config Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/installation.md Installs Tailwind CSS and its dependencies, then initializes the Tailwind configuration. ```bash npm install -D tailwindcss postcss autoprefixer npx tailwindcss init -p ``` -------------------------------- ### Getting session in .astro file Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Example of using Astro.locals to check session and redirect if not authenticated. The session is passed to a UserCard component. ```Astro --- import { UserCard } from "@/components/user-card"; const session = () => { if (Astro.locals.session) { return Astro.locals.session; } else { // Redirect to login page if the user is not authenticated return Astro.redirect("/login"); } } --- ``` -------------------------------- ### Server-side session handling with Better Auth Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Uses the auth instance to get session data on the server, with a protected action example. ```typescript "use server"; import { auth } from "~/server/auth"; import { headers } from "next/headers"; export const protectedAction = async () => { const session = await auth.api.getSession({ headers: await headers(), }); }; ``` -------------------------------- ### Basic Server Setup (src/index.ts) Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/getting-started.md Basic Express server setup using Effect for async startup, with middleware, routes, and a health check endpoint. ```typescript import express from "express" import cors from "cors" import helmet from "helmet" import { Effect, Layer } from "effect" import { config } from "./config" import { authRoutes } from "./routes/auth" const app = express() // Middleware app.use(helmet()) app.use(cors()) app.use(express.json()) // Routes app.use("/auth", authRoutes) // Health check app.get("/health", (req, res) => { res.json({ status: "ok", timestamp: new Date().toISOString() }) }) // Start server const startServer = Effect.gen(function*() { const { port } = yield* config return yield* Effect.async((resume) => { const server = app.listen(port, () => { console.log(`Server running on port ${port}`) resume(Effect.succeed(void 0)) }) server.on("error", (error) => { resume(Effect.fail(error)) }) }) }) // Run the server Effect.runPromise(startServer).catch(console.error) ``` -------------------------------- ### Get Session with auth.api.getSession in Popular Frameworks Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Examples of retrieving the session object using auth.api.getSession in various frameworks. Each example requires passing the request headers object to the getSession method. The session object is used to access session data on the server side. ```ts import { auth } from "./auth"; // path to your Better Auth server instance import { headers } from "next/headers"; const session = await auth.api.getSession({ headers: await headers() // you need to pass the headers object. }) ``` ```ts import { auth } from "lib/auth"; // path to your Better Auth server instance export async function loader({ request }: LoaderFunctionArgs) { const session = await auth.api.getSession({ headers: request.headers }) return json({ session }) } ``` ```astro --- import { auth } from "./auth"; const session = await auth.api.getSession({ headers: Astro.request.headers, }); --- ``` ```ts import { auth } from "./auth"; export async function load({ request }) { const session = await auth.api.getSession({ headers: request.headers }) return { props: { session } } } ``` ```ts import { auth } from "./auth"; const app = new Hono(); app.get("/path", async (c) => { const session = await auth.api.getSession({ headers: c.req.raw.headers }) }); ``` ```ts import { auth } from "~/utils/auth"; export default defineEventHandler((event) => { const session = await auth.api.getSession({ headers: event.headers, }) }); ``` ```ts import { auth } from "./auth"; import { createAPIFileRoute } from "@tanstack/start/api"; export const APIRoute = createAPIFileRoute("/api/$")({ GET: async ({ request }) => { const session = await auth.api.getSession({ headers: request.headers }) }, }); ``` -------------------------------- ### Run the live scheduling example Source: https://github.com/devx-op/effectify/blob/master/packages/hatchet/README.md Runs the live scheduling example. Requires a valid HATCHET_CLIENT_TOKEN. ```sh HATCHET_CLIENT_TOKEN='' node --experimental-strip-types packages/hatchet/scripts/test-schedule.ts ``` -------------------------------- ### Sign in with email using auth.api (TanStack Start) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Example of calling signInEmail via auth.api. This function sets cookies, which are automatically handled by the reactStartCookies plugin. ```TypeScript import { auth } from "@/lib/auth" const signIn = async () => { await auth.api.signInEmail({ body: { email: "user@email.com", password: "password", } }) } ``` -------------------------------- ### Hono handler for Better Auth Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Use this handler to integrate Better Auth with a Hono server. It registers POST and GET routes for /api/auth/** and starts the server with @hono/node-server. ```ts import { Hono } from "hono"; import { auth } from "./auth"; // path to your auth file import { serve } from "@hono/node-server"; import { cors } from "hono/cors"; const app = new Hono(); app.on(["POST", "GET"], "/api/auth/**", (c) => auth.handler(c.req.raw)); serve(app); ``` -------------------------------- ### Install better-auth with bun Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Use this command to install the Better Auth client library using bun. ```bash bun add better-auth ``` -------------------------------- ### Create vanilla client (lib/auth-client.ts) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Import createAuthClient from 'better-auth/client' and export the client instance. ```ts import { createAuthClient } from "better-auth/client" export const authClient = createAuthClient() ``` -------------------------------- ### MongoDB adapter setup in auth.ts Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Configure Better Auth with a MongoDB adapter. Requires MongoDB installed and configured. The adapter is imported from "better-auth/adapters/mongodb" and passed to the database option. ```ts import { betterAuth } from "better-auth"; import { MongoClient } from "mongodb"; import { mongodbAdapter } from "better-auth/adapters/mongodb"; const client = new MongoClient("mongodb://localhost:27017/database"); const db = client.db(); export const auth = betterAuth({ database: mongodbAdapter(db), }); ``` -------------------------------- ### Show project details for React Remix example Source: https://github.com/devx-op/effectify/blob/master/openspec/changes/archive/2026-08-26-consolidate-react-remix-into-router/apply-progress.md Displays project configuration including typegen, typecheck, and build dependencies. ```bash pnpm nx show project @effectify/react-remix-example --json ``` -------------------------------- ### Use getSessionFromCtx helper in a Better Auth plugin Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt getSessionFromCtx allows you to get the client's session data by passing the auth middleware's context. This example shows it used inside a before hook. ```TypeScript import { createAuthMiddleware } from "better-auth/plugins"; const myPlugin = { id: "my-plugin", hooks: { before: [{ matcher: (context)=>{ return context.headers.get("x-my-header") === "my-value" }, handler: createAuthMiddleware(async (ctx) => { const session = await getSessionFromCtx(ctx); //do something with the client's session. return { context: ctx } }) }], } } satisfies BetterAuthPlugin ``` -------------------------------- ### Install @prisma/client (yarn) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Prisma client as a runtime dependency using yarn. ```bash yarn add @prisma/client ``` -------------------------------- ### Mount Better Auth handler in TanStack Start (src/routes/api/auth/$.ts) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Mounts the Better Auth handler to a TanStack API endpoint. Create this file at the specified path. The handler responds to GET and POST requests. ```TypeScript import { auth } from '@/lib/auth' // import your auth instance import { createServerFileRoute } from '@tanstack/react-start/server' export const ServerRoute = createServerFileRoute('/api/auth/$').methods({ GET: ({ request }) => { return auth.handler(request) }, POST: ({ request }) => { return auth.handler(request) }, }) ``` -------------------------------- ### After hook: send notification on user registration Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Example of an after hook that sends a notification when a new user signs up. It checks if the path starts with '/sign-up' and if a new session exists, then sends a message with the user's name. ```TypeScript import { betterAuth } from "better-auth"; import { createAuthMiddleware } from "better-auth/api"; import { sendMessage } from "@/lib/notification" export const auth = betterAuth({ hooks: { after: createAuthMiddleware(async (ctx) => { if(ctx.path.startsWith("/sign-up")){ const newSession = ctx.context.newSession; if(newSession){ sendMessage({ type: "user-register", name: newSession.user.name, }) } } }), }, }); ``` -------------------------------- ### Install @prisma/client (pnpm) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Prisma client as a runtime dependency using pnpm. ```bash pnpm add @prisma/client ``` -------------------------------- ### Effectify development commands Source: https://github.com/devx-op/effectify/blob/master/README.md Development commands for the Effectify monorepo. Requires Node.js 24.19.0 and pnpm 10.14.0. Includes dependency installation, running the Solid example, building affected packages, formatting checks, and React Router 8 consolidation verification. ```bash # Install dependencies pnpm install # Run the maintained Solid example pnpm nx dev @effectify/solid-example # Build affected packages pnpm nx affected -t build # Check or apply pinned formatting to changed files pnpm format:check pnpm format # Verify React Router 8 consolidation and readiness pnpm nx run @effectify/react-router-example:consolidation:verify pnpm nx run @effectify/react-router-example:migration:manifest pnpm nx run @effectify/react-router-example:migration:verify ``` -------------------------------- ### Create client instance (vanilla) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Import createAuthClient from 'better-auth/client' and create a client with the base URL of the auth server. The baseURL is highlighted as the key configuration. ```typescript import { createAuthClient } from "better-auth/client" export const authClient = createAuthClient({ baseURL: "http://localhost:3000" // The base URL of your auth server // [!code highlight] }) ``` -------------------------------- ### MS SQL adapter setup in auth.ts Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Configure Better Auth with MS SQL using Kysely's MssqlDialect. Requires MS SQL installed and configured. The dialect is created with Tarn and Tedious connection settings and passed to the database option with type "mssql". ```ts import { betterAuth } from "better-auth"; import { MssqlDialect } from "kysely"; import * as Tedious from 'tedious' import * as Tarn from 'tarn' const dialect = new MssqlDialect({ tarn: { ...Tarn, options: { min: 0, max: 10, }, }, tedious: { ...Tedious, connectionFactory: () => new Tedious.Connection({ authentication: { options: { password: 'password', userName: 'username', }, type: 'default', }, options: { database: 'some_db', port: 1433, trustServerCertificate: true, }, server: 'localhost', }), }, }) export const auth = betterAuth({ database: { dialect, type: "mssql" } }); ``` -------------------------------- ### Install Dub SDK with bun Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Dub SDK on your server using bun. ```bash bun add dub ```