Server Hooks in Svelte

From the SvelteKit cheat sheet · Hooks · verified Nov 2026

Server Hooks

Server-side request/response handling

javascript
// src/hooks.server.js
export async function handle({ event, resolve }) {
  // Runs for every request
  const response = await resolve(event);
  return response;
}
🔒 Authentication and authorization
🛡️ Security headers and CORS
📌 handleError({ kind, error, event }) receives every error
⚡ Transform responses before sending

Continue with SvelteKit

Save the full cheat sheet or work through every related task.

More Svelte tasks

Back to the full SvelteKit cheat sheet