Server Endpoints in Svelte

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

Server Endpoints

Creating RESTful API endpoints

javascript
// +server.js
export async function GET() {
  return Response.json({ message: 'Hello' });
}

export async function POST({ request }) {
  const data = await request.json();
  return Response.json({ received: data }, { status: 201 });
}
๐Ÿ”— RESTful endpoints with +server.js files
๐Ÿ”’ Access to cookies and authentication
๐Ÿ“Š Full HTTP method support
๐Ÿ“Œ Return Response.json(), the json() helper is deprecated

Continue with SvelteKit

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

More Svelte tasks

Back to the full SvelteKit cheat sheet