Skip to content
Discussion options

You must be logged in to vote

You probably want to rethink about how you implemented your load and save handle hooks.
To me it looks like you want to populate locals before sveltekit does it´s stuff and save the state to redis when its done.
If that is the case, you can (and should) combine the logic into a single handle hook:

const load = async ({ resolve, event }) => {
  const sid = event.cookies.get("myauthcookie");

  // load the state
  event.locals = redisGetAndParse(sid);

  // sveltekit stuff
  const response = await resolve(event);

  // response may be a redirect but we don´t really care
  // we just want to do some stuff after the request is created

  // save the state
  redisStringifyAndSet(sid, event.locals

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@MikeMcDonald83
Comment options

Answer selected by MikeMcDonald83
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants