Svelte · Junior · Question 54 of 76

What file creates an API endpoint in SvelteKit?

// src/routes/api/hello/+server.js
export function GET() {
  return Response.json({ message: "Hello" });
}

Explanation

Handlers receive a request event and return a standard Response. SvelteKit is built on web standards like Request, Response and FormData.

Further reading

Problem with a question

Svelte · Junior · question 54

Test yourself

Take the Svelte · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz