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

Fix and Improve withPageAuthRequired Documentation #1750

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 13 additions & 6 deletions src/helpers/with-page-auth-required.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ export type WithPageAuthRequiredAppRouterOptions = {
* // app/protected-page/page.js
* import { withPageAuthRequired } from '@auth0/nextjs-auth0';
*
* export default function withPageAuthRequired(ProtectedPage() {
* const ProtectedPage = withPageAuthRequired(async function ProtectedPage() {
* return <div>Protected content</div>;
* }, { returnTo: '/protected-page' });
*
* export default ProtectedPage;
* ```
*
* If the user visits `/protected-page` without a valid session, it will redirect the user to the
Expand All @@ -153,15 +155,20 @@ export type WithPageAuthRequiredAppRouterOptions = {
*
* ```js
* // app/protected-page/[slug]/page.js
* import { withPageAuthRequired } from '@auth0/nextjs-auth0';
*
* export default function withPageAuthRequired(ProtectedPage() {
* return <div>Protected content</div>;
* import { AppRouterPageRouteOpts, withPageAuthRequired } from '@auth0/nextjs-auth0';
*
* const ProtectedPage = withPageAuthRequired(async function ProtectedPage({
* params, searchParams
* }: AppRouterPageRouteOpts) {
* const slug = params?.slug as string;
* return <div>Protected content for {slug}</div>;
* }, {
* returnTo({ params }) {
* return `/protected-page/${params.slug}`
* return `/protected-page/${params?.slug}`;
* }
* });
*
* export default ProtectedPage;
* ```
*
* @category Server
Expand Down