Skip to content

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

@yetty

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions