nextjs-auth0 icon indicating copy to clipboard operation
nextjs-auth0 copied to clipboard

App router: Allow types for page params/searchParams for pages wrapped by withPageAuthRequired

Open andrinheusser opened this issue 7 months ago • 0 comments

  • [x] All new/changed/fixed functionality is covered by tests (or N/A)
  • [x] I have added documentation for all new/changed functionality (or N/A)

📋 Changes

This PR contains only changes to types.

Using NextJs 14, you may now type your Pages wrapped by withPageAuthRequired

export default withPageAuthRequired(
  async function Home({
    params,
    searchParams: { limit },
  }: {
    searchParams: { limit: string };
    params: { lang: string; slug: string };
  }) {
    console.log(params, limit);
    return <div />;
  },
  {
    returnTo: ({ params, searchParams }) =>
      `/${params.lang}?limit=${searchParams.limit}`,
  }
)

previously, this would generate type errors: (@auth0/nextjs-auth0 3.5.0) image

📎 References

This should close https://github.com/auth0/nextjs-auth0/pull/1750/files

🎯 Testing

  • [x] added tests for types

andrinheusser avatar Jul 22 '24 20:07 andrinheusser