Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(/nextjs/custom-signup-signin-pages) Update guide #1739

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 18 additions & 40 deletions docs/references/nextjs/custom-signup-signin-pages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,31 @@ If the prebuilt components don't meet your specific needs or if you require more
<Steps>
### Build a sign-up page

Create a new file that will be used to render the sign-up page. In the file, import the [`<SignUp />`](/docs/components/authentication/sign-up) component from `@clerk/nextjs` and render it.
The following example demonstrates how to render the [`<SignUp />`](/docs/components/authentication/sign-up) component.

<CodeBlockTabs type="router" options={["App Router", "Pages Router"]}>
```tsx {{ filename: 'app/sign-up/[[...sign-up]]/page.tsx' }}
import { SignUp } from '@clerk/nextjs'
```tsx {{ filename: 'app/sign-up/[[...sign-up]]/page.tsx' }}
import { SignUp } from '@clerk/nextjs'

export default function Page() {
return <SignUp />
}
```

```tsx {{ filename: '/pages/sign-up/[[...index]].tsx' }}
import { SignUp } from '@clerk/nextjs'

export default function Page() {
return <SignUp />
}
```
</CodeBlockTabs>
export default function Page() {
return <SignUp />
}
```

### Build a sign-in page

Create a new file that will be used to render the sign-in page. In the file, import the [`<SignIn />`](/docs/components/authentication/sign-in) component from `@clerk/nextjs` and render it.
The following example demonstrates how to render the [`<SignIn />`](/docs/components/authentication/sign-in) component.

<CodeBlockTabs type="router" options={["App Router", "Pages Router"]}>
```tsx {{ filename: 'app/sign-in/[[...sign-in]]/page.tsx' }}
import { SignIn } from '@clerk/nextjs'
```tsx {{ filename: 'app/sign-in/[[...sign-in]]/page.tsx' }}
import { SignIn } from '@clerk/nextjs'

export default function Page() {
return <SignIn />
}
```

```tsx {{ filename: '/pages/sign-in/[[...index]].tsx' }}
import { SignIn } from '@clerk/nextjs'

export default function Page() {
return <SignIn />
}
```
</CodeBlockTabs>
export default function Page() {
return <SignIn />
}
```

### Make the sign-up and sign-in routes public

By default, `clerkMiddleware()` makes all routes public. This step is specifically for applications that have configured `clerkMiddleware()` to make [all routes protected](/docs/references/nextjs/clerk-middleware#protect-all-routes). If you have not configured `clerkMiddleware()` to protect all routes, you can skip this step.
By default, `clerkMiddleware()` makes all routes public. **This step is specifically for applications that have configured `clerkMiddleware()` to make [all routes protected](/docs/references/nextjs/clerk-middleware#protect-all-routes).** If you have not configured `clerkMiddleware()` to protect all routes, you can skip this step.

To make the sign-up and sign-in routes public:

Expand Down Expand Up @@ -93,9 +73,7 @@ If the prebuilt components don't meet your specific needs or if you require more

### Update your environment variables

In the previous steps, a `path` prop is passed to the `<SignIn />` and `<SignUp />` components. This is because the components need to know which route they are originally mounted on.

In Next.js applications, you can either pass the `path` prop, _or_ you can define the `NEXT_PUBLIC_CLERK_SIGN_IN_URL` and `NEXT_PUBLIC_CLERK_SIGN_UP_URL` environment variables, like so:
Update your environment variables to point to your custom sign-in and sign-up pages. Learn more about the available [environment variables](/docs/deployments/clerk-environment-variables).

```env {{ filename: '.env.local' }}
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
Expand All @@ -104,7 +82,7 @@ If the prebuilt components don't meet your specific needs or if you require more

### Visit your new pages

Run your project with the following terminal command from the root directory of your project:
Run your project with the following command:

<CodeBlockTabs options={["npm", "yarn", "pnpm"]}>
```bash {{ filename: 'terminal' }}
Expand All @@ -131,7 +109,7 @@ If the prebuilt components don't meet your specific needs or if you require more

---

- [Client Side Helpers](/docs/references/nextjs/overview#client-side-helpers)
- [Client-side helpers](/docs/references/nextjs/overview#client-side-helpers)
- Learn more about Next.js client-side helpers and how to use them.

---
Expand Down
Loading