fsl.tools
// Hooks r05

Payload-aware actions

Most actions carry data — a form submission, a server response, a user id. Pass it through with the transition and read it in the hook.

Code

session.hooks.ts
session.go('login', { user });

session.hook_action('login', ({ data }) => {
  currentUser = data.user;
  router.push('/dashboard');
});

// the payload travels with the action, not in module state