Replies: 1 comment 2 replies
-
I'm not sure I entirely what you want to achieve. In the Next.js integration, we suggest to use a middleware to protect routes directly server-side: https://docs.fief.dev/integrate/javascript/ssr/nextjs/#2-add-the-middleware By doing this, you can make sure that, when a route is accessed, the user is correctly authenticated. So there is no need to have dedicated logic on the client side. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We're working with a stack that includes NextJS, Fief, and OpenAPI, and our goal is to make an OpenAPI call from the client side using the user token if exists.
However, we lack of a method to determine whether the user is authenticated or not before making the OpenAPI call. We couldn't find any functionality in the Fief API to check its loading or authentication state.
We followed the NextJS integration route, and have:
Inside of a page, we use
useFiefAccessTokenInfo()
. It is by default null, but may change later with user information if they exists.We tried an approach with another wrapper like:
But it stay on Loading if user is not authenticated.
We want to know if the user is authenticated or not before doing an API call.
What would be the approach ?
Beta Was this translation helpful? Give feedback.
All reactions