Skip to content

Commit ca2f398

Browse files
tusharpandey13aliststevenwong-oktadesusai7klobucar
authored
pr 1750 (#2158)
Co-authored-by: Alexander Hoekje List <atlex2@gmail.com> Co-authored-by: Steven Wong <steven.wong@okta.com> Co-authored-by: Desu Sai Venkat <48179357+desusai7@users.noreply.github.com> Co-authored-by: Jonathon Klobucar <jonathon.klobucar@gmail.com> Co-authored-by: Sambego <sambellen@gmail.com> Co-authored-by: Frederik Prijck <frederik.prijck@okta.com> Co-authored-by: Frederik Prijck <frederik.prijck@auth0.com> Co-authored-by: arpit-jain_atko <arpit.jain@okta.com> Co-authored-by: Arpit Jain <167312832+arpit-jn@users.noreply.github.com> Co-authored-by: Filip Skokan <filip.skokan@okta.com> Co-authored-by: simon-debruijn <simon.debruijn@hotmail.com>
1 parent 61c0c2c commit ca2f398

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/helpers/with-page-auth-required.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ export type WithPageAuthRequiredAppRouterOptions = {
136136
* // app/protected-page/page.js
137137
* import { withPageAuthRequired } from '@auth0/nextjs-auth0';
138138
*
139-
* export default function withPageAuthRequired(ProtectedPage() {
139+
* const ProtectedPage = withPageAuthRequired(async function ProtectedPage() {
140140
* return <div>Protected content</div>;
141141
* }, { returnTo: '/protected-page' });
142+
*
143+
* export default ProtectedPage;
142144
* ```
143145
*
144146
* If the user visits `/protected-page` without a valid session, it will redirect the user to the
@@ -153,15 +155,20 @@ export type WithPageAuthRequiredAppRouterOptions = {
153155
*
154156
* ```js
155157
* // app/protected-page/[slug]/page.js
156-
* import { withPageAuthRequired } from '@auth0/nextjs-auth0';
157-
*
158-
* export default function withPageAuthRequired(ProtectedPage() {
159-
* return <div>Protected content</div>;
158+
* import { AppRouterPageRouteOpts, withPageAuthRequired } from '@auth0/nextjs-auth0';
159+
*
160+
* const ProtectedPage = withPageAuthRequired(async function ProtectedPage({
161+
* params, searchParams
162+
* }: AppRouterPageRouteOpts) {
163+
* const slug = params?.slug as string;
164+
* return <div>Protected content for {slug}</div>;
160165
* }, {
161166
* returnTo({ params }) {
162-
* return `/protected-page/${params.slug}`
167+
* return `/protected-page/${params?.slug}`;
163168
* }
164169
* });
170+
*
171+
* export default ProtectedPage;
165172
* ```
166173
*
167174
* @category Server

0 commit comments

Comments
 (0)