You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/quickstarts/nextjs.mdx
+9-49Lines changed: 9 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -78,54 +78,10 @@ The final result should resemble the following:
78
78
79
79
</InjectKeys>
80
80
81
-
### Add `<ClerkProvider>` to your app
82
-
83
-
All Clerk hooks and components must be children of the [`<ClerkProvider>`](/docs/components/clerk-provider) component, which provides active session and user context.
84
-
85
-
Select your preferred router to learn how to make this data available across your entire app:
function MyApp({ Component, pageProps }:AppProps) {
115
-
return (
116
-
<ClerkProvider{...pageProps}>
117
-
<Component{...pageProps} />
118
-
</ClerkProvider>
119
-
);
120
-
}
121
-
exportdefaultMyApp;
122
-
```
123
-
</Tab>
124
-
</Tabs>
125
-
126
81
### Add Middleware to your application
127
82
128
-
`clerkMiddleware()` grants you access to user authentication state throughout your application, on any route or page. It also allows you to protect specific routes from unauthenticated users. To add `clerkMiddleware()` to your application, follow these steps:
83
+
[`clerkMiddleware()`](/docs/references/nextjs/clerk-middleware#clerk-middleware) grants you access to user authentication state throughout your application, on any route or page. It also allows you to protect specific routes from unauthenticated users. To add `clerkMiddleware()` to your application, follow these steps:
84
+
129
85
130
86
1. Create a `middleware.ts` file. Your `middleware.ts` file should be placed inside the root directory alongside `.env.local`, or inside the `src/` directory if you are using it.
131
87
2. In your middleware.ts, export Clerk's `clerkMiddleware()` helper:
@@ -140,7 +96,9 @@ Select your preferred router to learn how to make this data available across you
140
96
```
141
97
3. By default, `clerkMiddleware()` will not protect any routes. All routes are public and you must opt-in to protection for routes. See the [`clerkMiddleware()` reference](/docs/references/nextjs/clerk-middleware) to learn how to require authentication for specific routes.
142
98
143
-
### Create a header with Clerk components
99
+
### Add `<ClerkProvider>` and components to your app
100
+
101
+
All Clerk hooks and components must be children of the [`<ClerkProvider>`](/docs/components/clerk-provider) component, which provides active session and user context.
144
102
145
103
You can control which content signed in and signed out users can see with Clerk's [prebuilt components](/docs/components/overview). To get started, create a header for your users to sign in or out. To do this, you will use:
146
104
@@ -149,8 +107,10 @@ You can control which content signed in and signed out users can see with Clerk'
149
107
-[`<UserButton />`](/docs/components/user/user-button): A prebuilt component that comes styled out of the box to show the avatar from the account the user is signed in with.
150
108
-[`<SignInButton />`](/docs/components/unstyled/sign-in-button): An unstyled component that links to the sign-in page or displays the sign-in modal.
151
109
110
+
Select your preferred router to learn how to make this data available across your entire app:
0 commit comments