### Execute Project Setup and Management Commands Source: https://context7.com/joysofcode/sveltekit-remote-functions/llms.txt A collection of CLI commands for initializing the project, managing database schemas, and running the development server. These commands utilize pnpm and npx to streamline the workflow. ```bash npx degit joysofcode/sveltekit-remote-functions example pnpm install pnpm run db:push pnpm run dev pnpm run db:migrate pnpm run db:studio ``` -------------------------------- ### Initialize Database Connection Source: https://context7.com/joysofcode/sveltekit-remote-functions/llms.txt Sets up the Drizzle ORM connection using the libSQL client. Validates the presence of the DATABASE_URL environment variable before initializing. ```typescript import { drizzle } from 'drizzle-orm/libsql' import { createClient } from '@libsql/client' import { env } from '$env/dynamic/private' import * as schema from './schema' if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set') const client = createClient({ url: env.DATABASE_URL }) export const db = drizzle(client, { schema }) ``` -------------------------------- ### Configure Better Auth with Drizzle and SvelteKit Source: https://context7.com/joysofcode/sveltekit-remote-functions/llms.txt Initializes the Better Auth instance using the Drizzle adapter for SQLite and the SvelteKit cookies plugin. This setup enables email/password authentication and session cookie management. ```typescript import { betterAuth } from 'better-auth' import { drizzleAdapter } from 'better-auth/adapters/drizzle' import { sveltekitCookies } from 'better-auth/svelte-kit' import { db } from '$lib/server/database' import { getRequestEvent } from '$app/server' export const auth = betterAuth({ database: drizzleAdapter(db, { provider: 'sqlite' }), plugins: [sveltekitCookies(getRequestEvent)], emailAndPassword: { enabled: true } }) ``` -------------------------------- ### Configure Environment Variables Source: https://context7.com/joysofcode/sveltekit-remote-functions/llms.txt Defines the required environment variables for authentication and database connectivity. These should be placed in a .env file to ensure the application can access secrets and connection strings. ```bash BETTER_AUTH_SECRET=your-secret-key-here BETTER_AUTH_URL=http://localhost:3000 DATABASE_URL=file:local.db ``` -------------------------------- ### Fetch Data with Remote Functions Source: https://context7.com/joysofcode/sveltekit-remote-functions/llms.txt Demonstrates the use of remote query functions within Svelte 5 components using the await syntax to handle asynchronous data loading. ```svelte
No posts found
{/each}