Introducing Auth0's Next.js SDK

Learn how to add authentication with Auth0 to your Next.js apps using our newly released nextjs-auth0 SDK.
Read more…

Brought for you by @adam.mcgrath

3 Likes

We’re happy to help if you have any questions!

1 Like

Deleted previous message due to SPAM reasons

Hi thanks for this. Looks great. Is there a recommended way to use the new SDK with Hasura?

Hey there Glen!

I guess there isn’t as it’s fairly “new” SDK but that’s a good idea! I would highly encourage you to share that in our feedback category here:

Hey guys,

So I’m using auth0 to handle user login for an application with a nextjs frontend, which consumes an express API on the backend.

Everything works fine as far as the basis go, I used the following article to get the next.js side done:

https://auth0.com/blog/introducing-the-auth0-next-js-sdk/

Here’s my question: how do I lead users to the signup page directly? I’ve seen documentation to redirect to the signup page as follows:

You can make users land directly on the Signup page instead of the Login page by specifying the screen_hint=signup parameter when redirecting to /authorize .

Here’s the problem: I don’t see where that /authorize route comes from. It’s not mentioned anywhere in the next.js SDK. My users are lead to the login page by clicking on a link with the href: /api/auth/login.

I tried /api/auth/login?screen_hint=signup, but that doesn’t work, I tried /api/auth/signup, but that doesn’t work either.

How can I lead my users to the signup page using the next.js SDK?

Thank you.

2 Likes

Hey there!

Moving your post to this thread as this one is related with the blog article you referenced.

I’m also curious how to redirect to Sign Up page directly instead of the login page. Any ideas @konrad.sopala?

Thanks in advance!

Previous message deleted due to SPAM reasons

@konrad.sopala @robertino.calcaterra Could we get an update on @adrianhalac question about sending users directly to the signup tab instead of login?

Hey there!

Can I ask you to raise it as a GitHub issue in the Next.js SDK repo here:

I’m not a Next.js expert and this way we’ll be able to tackle that directly with the repo maintainers. Once you have a link to the issue please share it here so I can ping repo maintainers. Thank you!

Hi, I had exactly the same requirement.
I’ve ended up with additional custom handler, based on login handler. Just created page (e.g signup.ts) in /api/auth/ folder, with such code:

import { handleLogin } from '@auth0/nextjs-auth0';
import { NextApiRequest, NextApiResponse } from 'next';

const signupHandler = (req: NextApiRequest, res: NextApiResponse) =>
  handleLogin(req, res, {
    authorizationParams: {
      screen_hint: 'signup',
    },
  });

export default signupHandler;

So now, when I point to /api/auth/signup - user is redirected to auth0 signup screen.
BTW I’m using New Universal Login

8 Likes

Thanks for sharing that with the rest of community!

This should be marked as the answer

2 Likes

Thank you! You have just made my day. It was driving me crazy!

2 Likes

Woooohoooo teamwork makes the dreamwork!

1 Like

Thank you from the future :slight_smile:

Hi, can you also tell how to do it in nextjs 13 app router?

Hi @farhang, welcome to the Auth0 community.

You can read about the SDKs integration with app router here:

Have a great day!

thank you, but I already knew that, I want to know the folder path for this, is it like this:
/api/auth/[auth0]/signup/route.ts ?