Auth0 and NextJS Server Actions

I am starting a new project with NextJS 14 (that uses a Django API as backend) and am excited to switch from the traditional route handlers to Server Actions for fetching and mutating data. These Server Actions will be in a separate Data Access Layer in my codebase, according to NextJS’ recommended practices.

If I want to avoid using the traditional Auth0 route handlers (I’d basically just be creating an ‘api’ directory just for this purpose), is it possible to put the dynamic route with the handleAuth() method into a Server Action instead, or would this preclude me from using the SDK?

Also, regardless of the answer to the above question, can I use the getSession() method within Server Actions also?

TLDR; I’d like to know how to use the nextjs-auth0 SDK primarily with NextJS Server Actions (in an separate DAL in my codebase).


Yeah, I do have this question cause the Doc haven’t include how to protect server action. But I try to call getSession() in my server action function directly, and it seems does work. So I use it to protect my server action now as an walkaround. Hope Auth0 can support server actions.

1 Like

Hi jenergy

Do you have any idea of how to retrieve the permissions assigned to the user in server action?