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
{{ message }}
This repository was archived by the owner on May 10, 2021. It is now read-only.
-[Fallbacks for Pages with `getStaticPaths`](#fallbacks-for-pages-with-getstaticpaths)
52
53
-[Credits](#credits)
@@ -199,6 +200,52 @@ Currently, there is no support for redirects set in your `netlify.toml` file.
199
200
`next-on-netlify` creates one Netlify Function for each of your
200
201
SSR pages and API endpoints. It is currently not possible to create custom Netlify Functions. This feature is on our list to do.
201
202
203
+
#### Using Netlify Identity
204
+
205
+
You can use [Netlify Identity](https://docs.netlify.com/visitor-access/identity/) with `next-on-netlify`. For all pages with server-side rendering (getInitialProps*, getServerSideProps, and API routes), you can access the [clientContext object](https://docs.netlify.com/functions/functions-and-identity/#access-identity-info-via-clientcontext) via the `req` parameter.
To access Netlify Identity from pages without server-side rendering, you can create a [Next API route](https://nextjs.org/docs/api-routes/introduction) that performs identity-related logic:
230
+
231
+
```js
232
+
exportdefaultasyncfunctiongetUser(req, res) {
233
+
// Get event and context from Netlify Function
234
+
const {
235
+
netlifyFunction: { event, context },
236
+
} = req;
237
+
238
+
// Access Netlify identity
239
+
const { user } =context.clientContext;
240
+
241
+
// Respond with user object
242
+
res.json({ user });
243
+
}
244
+
```
245
+
246
+
\* Note that pages using getInitialProps are only server-side rendered on initial page load and not when the user navigates client-side between pages.
0 commit comments