Svelte · Middle · Question 39 of 75

What is handle in hooks.server.js used for?

export async function handle({ event, resolve }) {
  event.locals.user = await getUser(event.cookies.get("session"));
  return resolve(event);
}

Explanation

event.locals is then available in server load functions, actions and endpoints for that request.

Further reading

Problem with a question

Svelte · Middle · question 39

Test yourself

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

Take this quiz