Skip to content

Best practice for getting access token inside React Router action? #34

Description

@yetty

I'm currently using @workos-inc/authkit-react-router in a React Router v7+ app and I have a question about how to access the access token inside an action() function (not a loader()).

In loader() functions, the pattern is clear via:

authkitLoader(args, async ({ getAccessToken }) => {
  const token = getAccessToken();
  // ...
});

However, what's the recommended or best-practice way to get the access token inside an action()?

Should I be using withAuth() for this?
Or is there another pattern you'd recommend?

A brief example would be much appreciated!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions