NextJS 13 integration using the App Directory

Does the nextjs-auth0 package work with the NextJS 13 experimental app directory?

The documentation and examples for using nextjs-auth0 for NextJS 12.x using the _app.ts file are very clear and straight forward and I have that working as expected. What’s the correct way to implement nextjs-auth0 in NextJS 13.x? I tried moving the wrapper element to a root layout.ts or template.ts file and even leaving it in _app.ts, but trying to use the useUser() hook from within a page in the /app directory results in an error about useUser() not being a function.

I can’t seem to find any code examples for how to use nextjs-auth0 with the app directory. Any help appreciated.

3 Likes

I would also like to know this

2 Likes

I am very much interested too. A element of my choice between Next and Nuxt was indeed the existence of the Auth0-Next integration.

1 Like

Looks like Auth0 support for NextJS 13 is still pending the official stable release of Next’s app directory. See this thread on the repo - NextJS 13: support for server-side components in nextjs-auth0 · Issue #889 · auth0/nextjs-auth0 · GitHub

1 Like

I think this will become quite important to auth0. The nextjs-auth0 package is a nice community effort, but I do not think they are a relevant blocker or decision maker. The nextjs app dir and server rendered components could possibly be treated simply like any server API. We would want auth0 to take a closer look and put out recommendations or examples on how to build against nextjs 13 app dir.

The app directory is now in stable release as of Nextjs 13.4.0. When can we expect the Auth0 package to support the app directory?

7 Likes

For those who still keep landing here, this feature will be added in v3 of the Auth0 NextJS npm package. You can follow the v3 development progress in this github issue. They are aiming to release by the end of July.

Support is now live in v3 of the NPM package :+1:

1 Like

Thank you for keeping us updated!

1 Like