ワンクリックで
auth-patterns
// Better-auth integration for authentication. Use when implementing login, registration, protected routes, or email verification.
// Better-auth integration for authentication. Use when implementing login, registration, protected routes, or email verification.
Database migration patterns for SQLite. Use when creating migrations, modifying schema, or running database changes.
Remote functions reactive UI patterns. Use for smooth in-place updates, preventing page jumps, and managing loading states with .current property.
SvelteKit patterns for devhub-crm. Use for remote functions (query, form, command), routing, and server-side logic.
Vitest browser mode component testing. Use for testing Svelte 5 components with real browsers, locators, accessibility patterns, and reactive state.
SQLite operations using better-sqlite3 with prepared statements. Use when implementing CRUD operations, timestamps, and user-scoped queries with row-level security.
Svelte 5 error handling. Use for error boundaries, async await expressions, loading states, and form errors.
| name | auth-patterns |
| description | Better-auth integration for authentication. Use when implementing login, registration, protected routes, or email verification. |
// Login form
export const login = form(schema, async ({ email, password }) => {
const event = getRequestEvent();
await auth.api.signInEmail({
body: { email, password },
headers: event.request.headers,
});
redirect(303, '/dashboard'); // Outside try/catch
});
// Protected query
export const get_data = guarded_query(() => {
return { message: 'Protected data' };
});
getRequestEvent() for headers (cookie access)guarded_query/form/command for protected endpointsgoto()