Next.js Auth0 | External API service (without /api directory)

Hi everyone

We have an existing API service that we started building a few weeks ago. We’re about to kick off the frontend development using Next.js soon.

We looked at the example projects and docs of the Next.js Auth0 lib, it seems all the examples require an API service (/api/auth/[...auth0].js) to handle auth on the backend of the Next.js project.

Is there any way to use Next.js with Auth0, but only the frontend side of it (similar to a plain React app)? We don’t want to use the API service feature of the Next.js (just because our API service is already built, and lives on a production infrastructure).

Note: We tried to mimic the React project, but it seems we try to hack it, and thus, we couldn’t get it right.

Information

  • SDK: nextjs-auth0
  • SDK Version: 1.9.1
  • Platform Version: 12.1.6
2 Likes

We are having the same issue. Any insight here would be greatly appreciated.

2 Likes

Did you guys ever figure this out?

For what it’s worth, we have a workaround by passing the accessToken to the frontend.
I have a brief example code here: Next.js & External API without Proxying requests through Next.js backend

I’m just looking for some kind of official confirmation that this is safe to do.

1 Like