SpinUp
October 2, 2023, 3:44pm
1
Every time I set up a new auth0, and something has changed in Next, I struggle to work out how to have a “Sign up” link. Does anyone know how to do it with the new App router?
At the moment I just have the /api/auth/[auth0]/route.js
file with the code below. But I’m not sure how to link to like /api/auth/register
or /api/auth/signup
import { handleAuth } from '@auth0/nextjs-auth0';
export const GET = handleAuth();
tyf
October 3, 2023, 10:40pm
2
Hey @SpinUp welcome back!
You should be able to achieve this with the signup handler outlined here:
# Examples
- [Create your own instance of the SDK](#create-your-own-instance-of-the-sdk)
- [Customize handlers behavior](#customize-handlers-behavior)
- [Use custom auth urls](#use-custom-auth-urls)
- [Protecting a Server-Side Rendered (SSR) Page](#protecting-a-server-side-rendered-ssr-page)
- [Protecting a Client-Side Rendered (CSR) Page](#protecting-a-client-side-rendered-csr-page)
- [Protect an API Route](#protect-an-api-route)
- [Protecting pages with Middleware](#protecting-pages-with-middleware)
- [Access an External API from an API Route](#access-an-external-api-from-an-api-route)
- [Add a signup handler](#add-a-signup-handler)
- [Use with Base Path and Internationalized Routing](#use-with-base-path-and-internationalized-routing)
- [Use a custom session store](#use-a-custom-session-store)
- [Back-Channel Logout](#back-channel-logout)
See also the [example app](./example-app).
### Create your own instance of the SDK
When you use the named exports, the SDK creates an instance of the SDK for you and configures it with the provided environment variables.
This file has been truncated. show original
SpinUp
October 4, 2023, 9:51am
4
Thanks! This worked a treat, I just had to tweak it for the Next 13.4 App Router, which requires a method function (GET in this case).
import { handleAuth, handleLogin } from "@auth0/nextjs-auth0";
export const GET = handleAuth({
signup: handleLogin({ authorizationParams: { screen_hint: "signup" } }),
});
1 Like
tyf
October 4, 2023, 9:29pm
5
Awesome, thanks for confirming! Happy to help
system
Closed
October 18, 2023, 9:29pm
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.