Skip to content

Commit f54f425

Browse files
wassimoovinckr
authored andcommitted
docs: add browser redirects configuration and custom component instructions for Next.js integration
1 parent 8be711e commit f54f425

File tree

3 files changed

+55
-23
lines changed

3 files changed

+55
-23
lines changed
87.5 KB
Loading

docs/getting-started/integrate-auth/16_nextjs_app_router.mdx

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,23 @@ all files referenced as being in the `root` directory inside `src/` instead.
101101
src="https://raw.githubusercontent.com/ory/elements/refs/heads/main/examples/nextjs-app-router/middleware.ts"
102102
/>
103103

104-
5. Create a new folder named `app` in the root of your project. Inside the `app` folder, create a new folder named `auth`. Inside
104+
5. Configure browser redirects in your Ory Console. Navigate to **Branding** > **Browser redirects** and set the **Global redirect
105+
URL** to `/ui/welcome`. This ensures users are redirected to the correct page after completing authentication flows.
106+
107+
![Browser Redirects Configuration](../_static/nextjs/branding_browser_redirects.png)
108+
109+
6. Create a new folder named `components` in the root of your project. Inside the `components` folder, create a new file named
110+
`custom-card-header.tsx` and add the following code:
111+
112+
<CodeFromRemote
113+
lang="tsx"
114+
title="components/custom-card-header.tsx"
115+
src="https://raw.githubusercontent.com/ory/elements/refs/heads/main/examples/nextjs-app-router/components/custom-card-header.tsx"
116+
/>
117+
118+
This component is used by the Verification and Settings pages to customize the card header.
119+
120+
7. Create a new folder named `app` in the root of your project. Inside the `app` folder, create a new folder named `auth`. Inside
105121
the `auth` folder, create the following files:
106122

107123
- `login/page.tsx`
@@ -155,7 +171,16 @@ all files referenced as being in the `root` directory inside `src/` instead.
155171
</Tabs>
156172
```
157173

158-
6. Run the application and create your first user by navigating to `/auth/registration`. After registration, you can log in at
174+
8. Use your own Ory Network project by setting the `ORY_SDK_URL` environment variable in your `.env` file:
175+
176+
```mdx-code-block
177+
<CodeFromRemote lang="bash" title=".env" src="https://raw.githubusercontent.com/ory/elements/refs/heads/main/examples/nextjs-app-router/.env" />
178+
```
179+
180+
You can find your Ory Network project URL in the [**Get started**](https://console.ory.sh/projects/current/get-started) section
181+
of the Ory Console.
182+
183+
9. Run the application and create your first user by navigating to `/auth/registration`. After registration, you can log in at
159184
`/auth/login`. You can also access the other self-service flows at the following URLs:
160185

161186
- Recovery: `/auth/recovery`
@@ -189,15 +214,6 @@ all files referenced as being in the `root` directory inside `src/` instead.
189214

190215
Open your browser and navigate to `http://localhost:3000/auth/registration` to create your first user.
191216

192-
7. Optional: use your own Ory Network project by setting the `ORY_SDK_URL` environment variable in your `.env` file:
193-
194-
```mdx-code-block
195-
<CodeFromRemote lang="bash" title=".env" src="https://raw.githubusercontent.com/ory/elements/refs/heads/main/examples/nextjs-app-router/.env" />
196-
```
197-
198-
You can find your Ory Network project URL in the [**Get started**](https://console.ory.sh/projects/current/get-started) section
199-
of the Ory Console.
200-
201217
## Next steps
202218

203219
Now that you have set up Ory Elements with the App Router in your Next.js application, you can further customize the components,

docs/getting-started/integrate-auth/17_nextjs_pages_router.mdx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,23 @@ The code used in the following quickstart is available in the
6464
src="https://raw.githubusercontent.com/ory/elements/refs/heads/main/examples/nextjs-pages-router/middleware.ts"
6565
/>
6666

67-
4. Create a new folder named `pages` in the root of your project. Inside the `pages` folder, create a new folder named `auth`.
67+
4. Configure browser redirects in your Ory Console. Navigate to **Branding** > **Browser redirects** and set the **Global redirect
68+
URL** to `/ui/welcome`. This ensures users are redirected to the correct page after completing authentication flows.
69+
70+
![Browser Redirects Configuration](../_static/nextjs/branding_browser_redirects.png)
71+
72+
5. Create a new folder named `components` in the root of your project. Inside the `components` folder, create a new file named
73+
`custom-card-header.tsx` and add the following code:
74+
75+
<CodeFromRemote
76+
lang="tsx"
77+
title="components/custom-card-header.tsx"
78+
src="https://raw.githubusercontent.com/ory/elements/refs/heads/main/examples/nextjs-app-router/components/custom-card-header.tsx"
79+
/>
80+
81+
This component is used by the Verification and Settings pages to customize the card header.
82+
83+
6. Create a new folder named `pages` in the root of your project. Inside the `pages` folder, create a new folder named `auth`.
6884
Inside the `auth` folder, create the following files:
6985

7086
- `login.tsx`
@@ -118,7 +134,16 @@ The code used in the following quickstart is available in the
118134
</Tabs>
119135
```
120136

121-
5. Run the application and create your first user by navigating to `/auth/registration`. After registration, you can log in at
137+
7. Use your own Ory Network project by setting the `ORY_SDK_URL` environment variable in your `.env` file:
138+
139+
```mdx-code-block
140+
<CodeFromRemote lang="bash" title=".env" src="https://raw.githubusercontent.com/ory/elements/refs/heads/main/examples/nextjs-pages-router/.env" />
141+
```
142+
143+
You can find your Ory Network project URL in the [**Get started**](https://console.ory.sh/projects/current/get-started) section
144+
of the Ory Console.
145+
146+
8. Run the application and create your first user by navigating to `/auth/registration`. After registration, you can log in at
122147
`/auth/login`. You can also access the other self-service flows at the following URLs:
123148

124149
- Recovery: `/auth/recovery`
@@ -152,18 +177,9 @@ The code used in the following quickstart is available in the
152177

153178
Open your browser and navigate to `http://localhost:3000/auth/registration` to create your first user.
154179

155-
6. Optional: use your own Ory Network project by setting the `ORY_SDK_URL` environment variable in your `.env` file:
156-
157-
```mdx-code-block
158-
<CodeFromRemote lang="bash" title=".env" src="https://raw.githubusercontent.com/ory/elements/refs/heads/main/examples/nextjs-pages-router/.env" />
159-
```
160-
161-
You can find your Ory Network project URL in the [**Get started**](https://console.ory.sh/projects/current/get-started) section
162-
of the Ory Console.
163-
164180
## Next steps
165181

166-
Now that you have set up Ory Elements with the App Router in your Next.js application, you can further customize the components,
182+
Now that you have set up Ory Elements with the Pages Router in your Next.js application, you can further customize the components,
167183
add your own styles, and integrate them into your application as needed. You can also explore the Ory Elements documentation for
168184
more information on how to use the components and customize them to fit your needs. See
169185
[Theming](../../elements/guides/02_theming.mdx) for more details on how to customize look and feel of the components.

0 commit comments

Comments
 (0)