Server Endpoints in Svelte

From the SvelteKit cheat sheet ยท API Routes ยท verified Jul 2026

Server Endpoints

Creating RESTful API endpoints

javascript
// +server.js
import { json } from '@sveltejs/kit';

export async function GET() {
  return json({ message: 'Hello' });
}

export async function POST({ request }) {
  const data = await request.json();
  return json({ received: data });
}
๐Ÿ”— RESTful endpoints with +server.js files
๐Ÿ”’ Access to cookies and authentication
๐Ÿ“Š Full HTTP method support
โšก Automatic error handling and status codes

More Svelte tasks

Back to the full SvelteKit cheat sheet