Next.js Discord

Discord Forum

How to restrict a page with auth0?

Unanswered
Giant panda posted this in #help-forum
Open in Discord
Giant pandaOP
I am trying to restrict access to a page using auth0.

The code below works fine HOWEVER , I get a typescript error when I try to compile it. Is there a more idiomatic way to restrict a page using auth0? Or is there some trick to get the types to work?

Code
"use client"
import { withPageAuthRequired } from "@auth0/nextjs-auth0/client";
export function Page() {

    // return <Call channelId={params.channel_id}></Call>


    return <div></div>
}


export default withPageAuthRequired(Page, {

})


Error:
 error TS2344: Type 'OmitWithTag<typeof import("app/[id]/page"), "default" | "config" | "generateStaticParams" | "revalidate" | "dynamic" | "dynamicParams" | ... 7 more ... | "generateViewport", "">' does not satisfy the constraint '{ [x: string]: never; }'.
  Property 'Page' is incompatible with index signature.
    Type '() => Element' is not assignable to type 'never'.

  8 checkFields<Diff<{
                ~~~~~~
  9   default: Function
    ~~~~~~~~~~~~~~~~~~~
... 
 24 
    
 25 }, TEntry, ''>>()
    ~~~~~~~~~~~~~~

0 Replies