Repository: auth0/nextjs-auth0
Pull request #913 (2022-11-18 12:29:09)

Rearrange exports for RSC and add experimental RSC route to example
### 📋 Changes

- moved `/frontend` -> `/client` to [align with Next.js](https://nextjs.org/learn/foundations/how-nextjs-works/client-and-server)
- moved client code out of the main export to `/client` (eg `import { useUser } from '@auth0/nextjs-auth0/client'`) because server components can't import client code
- moved `/middleware` -> `/edge`  (eg `import { withMiddlewareAuthRequired } from '@auth0/nextjs-auth0/edge'`) because this export will include code that can run on the Edge runtime in Server Components and API Routes in addition to Middleware.
 


Patch:
diff --git a/EXAMPLES.md b/EXAMPLES.md
index a79fb71f..05c3b664 100644
--- a/EXAMPLES.md
+++ b/EXAMPLES.md
@@ -40,7 +40,7 @@ Wrap your `pages/_app.jsx` component in the `UserProvider` component.
 ```jsx
 // pages/_app.jsx
 import React from 'react';
-import { UserProvider } from '@auth0/nextjs-auth0';
+import { UserProvider } from '@auth0/nextjs-auth0/client';
 
 export default function App({ Component, pageProps }) {
   // You can optionally pass the `user` prop from pages that require server-side
@@ -59,7 +59,7 @@ Check the user's authentication state and log them in or out from the front end
 
 ```jsx
 // pages/index.jsx
-import { useUser } from '@auth0/nextjs-auth0';
+import { useUser } from '@auth0/nextjs-auth0/client';
 
 export default () => {
   const { user, error, isLoading } = useUser();
@@ -167,7 +167,7 @@ Requests to `/pages/profile` without a valid session cookie will be redirected t
 
 ```jsx
 // pages/profile.js
-import { withPageAuthRequired } from '@auth0/nextjs-auth0';
+import { withPageAuthRequired } from '@auth0/nextjs-auth0/client';
 
 export default withPageAuthRequired(function Profile({ user }) {
   return <div>Hello {user.name}</div>;
@@ -195,7 +195,7 @@ Then you can access your API from the frontend with a valid session cookie.
 ```jsx
 // pages/products
 import useSWR from 'swr';
-import { withPageAuthRequired } from '@auth0/nextjs-auth0';
+import { withPageAuthRequired } from '@auth0/nextjs-auth0/client';
 
 const fetcher = async (uri) => {
   const response = await fetch(uri);
@@ -221,7 +221,7 @@ To protect all your routes:
 
 ```js
 // middleware.js
-import { withMiddlewareAuthRequired } from '@auth0/nextjs-auth0/middleware';
+import { withMiddlewareAuthRequired } from '@auth0/nextjs-auth0/edge';
 
 export default withMiddlewareAuthRequired();
 ```
@@ -230,7 +230,7 @@ To protect specific routes:
 
 ```js
 // middleware.js
-import { withMiddlewareAuthRequired } from '@auth0/nextjs-auth0/middleware';
+import { withMiddlewareAuthRequired } from '@auth0/nextjs-auth0/edge';
 
 export default withMiddlewareAuthRequired();
 
@@ -245,7 +245,7 @@ To run custom middleware for authenticated users:
 
 ```js
 // middleware.js
-import { withMiddlewareAuthRequired, getSession } from '@auth0/nextjs-auth0/middleware';
+import { withMiddlewareAuthRequired, getSession } from '@auth0/nextjs-auth0/edge';
 
 export default withMiddlewareAuthRequired(async function middleware(req) {
   const res = NextResponse.next();
@@ -262,8 +262,8 @@ For using middleware with your own instance of the SDK:
 import {
   withMiddlewareAuthRequired,
   getSession,
-  initAuth0 // note the mw specific `initAuth0`
-} from '@auth0/nextjs-auth0/middleware';
+  initAuth0 // note the edge runtime specific `initAuth0`
+} from '@auth0/nextjs-auth0/edge';
 
 const auth0 = initAuth0({ ... });
 
diff --git a/README.md b/README.md
index fce4a4fb..ad2c39c1 100644
--- a/README.md
+++ b/README.md
@@ -127,7 +127,7 @@ Wrap your `pages/_app.js` component with the `UserProvider` component:
 ```jsx
 // pages/_app.js
 import React from 'react';
-import { UserProvider } from '@auth0/nextjs-auth0';
+import { UserProvider } from '@auth0/nextjs-auth0/client';
 
 export default function App({ Component, pageProps }) {
   return (
@@ -144,7 +144,7 @@ You can now determine if a user is authenticated by checking that the `user` obj
 
 ```jsx
 // pages/index.js
-import { useUser } from '@auth0/nextjs-auth0';
+import { useUser } from '@auth0/nextjs-auth0/client';
 
 export default function Index() {
   const { user, error, isLoading } = useUser();
@@ -174,10 +174,12 @@ For other comprehensive examples, see the [EXAMPLES.md](./EXAMPLES.md) document.
 
 ### API Reference
 
-- [Configuration Options](https://auth0.github.io/nextjs-auth0/modules/config.html)
+#### Server (for Node.js)
 
-**Server-side methods**:
+`import * from @auth0/nextjs-auth0`
 
+- [Configuration Options and Environment variables](https://auth0.github.io/nextjs-auth0/modules/config.html)
+- [initAuth0](https://auth0.github.io/nextjs-auth0/modules/index.html#initauth0)
 - [handleAuth](https://auth0.github.io/nextjs-auth0/modules/handlers_auth.html)
 - [handleLogin](https://auth0.github.io/nextjs-auth0/modules/handlers_login.html#handlelogin)
 - [handleCallback](https://auth0.github.io/nextjs-auth0/modules/handlers_callback.html)
@@ -185,19 +187,34 @@ For other comprehensive examples, see the [EXAMPLES.md](./EXAMPLES.md) document.
 - [handleProfile](https://auth0.github.io/nextjs-auth0/modules/handlers_profile.html)
 - [withApiAuthRequired](https://auth0.github.io/nextjs-auth0/modules/helpers_with_api_auth_required.html)
 - [withPageAuthRequired](https://auth0.github.io/nextjs-auth0/modules/helpers_with_page_auth_required.html#withpageauthrequired)
-- [withMiddlewareAuthRequired](https://auth0.github.io/nextjs-auth0/modules/helpers_with_middleware_auth_required.html)
 - [getSession](https://auth0.github.io/nextjs-auth0/modules/session_get_session.html)
 - [updateSession](https://auth0.github.io/nextjs-auth0/modules/session_update_session.html)
 - [getAccessToken](https://auth0.github.io/nextjs-auth0/modules/session_get_access_token.html)
-- [initAuth0](https://auth0.github.io/nextjs-auth0/modules/instance.html)
 
-**Client-side methods/components**:
+#### Edge (for Middleware and the Edge runtime)
+
+`import * from @auth0/nextjs-auth0/edge`
+
+- [Configuration Options and Environment variables](https://auth0.github.io/nextjs-auth0/modules/config.html)
+- [initAuth0](https://auth0.github.io/nextjs-auth0/modules/edge.html#initauth0-1)
+- [withMiddlewareAuthRequired](https://auth0.github.io/nextjs-auth0/modules/helpers_with_middleware_auth_required.html)
+- [getSession](https://auth0.github.io/nextjs-auth0/modules/edge.html#getsession-1)
+
+#### Client (for the Browser)
+
+`import * from @auth0/nextjs-auth0/client`
+
+- [UserProvider](https://auth0.github.io/nextjs-auth0/modules/client_use_user.html#userprovider)
+- [useUser](https://auth0.github.io/nextjs-auth0/modules/client_use_user.html)
+- [withPageAuthRequired](https://auth0.github.io/nextjs-auth0/modules/client_with_page_auth_required.html)
+
+#### Testing helpers
+
+`import * from @auth0/nextjs-auth0/testing`
 
-- [UserProvider](https://auth0.github.io/nextjs-auth0/modules/frontend_use_user.html#userprovider)
-- [useUser](https://auth0.github.io/nextjs-auth0/modules/frontend_use_user.html)
-- [withPageAuthRequired](https://auth0.github.io/nextjs-auth0/modules/frontend_with_page_auth_required.html)
+- [generateSessionCookie](https://auth0.github.io/nextjs-auth0/modules/helpers_testing.html#generatesessioncookie)
 
-Visit the auto-generated [API Docs](https://auth0.github.io/nextjs-auth0/) for more details.
+Visit the auto-generated [API Docs](https://auth0.github.io/nextjs-auth0/) for more details
 
 ### Cookies and Security
 
diff --git a/V2_MIGRATION_GUIDE.md b/V2_MIGRATION_GUIDE.md
index fd121bf0..a9de3116 100644
--- a/V2_MIGRATION_GUIDE.md
+++ b/V2_MIGRATION_GUIDE.md
@@ -4,6 +4,7 @@ Guide to migrating from `1.x` to `2.x`
 
 - [Node 10 is no longer supported](#node-10-is-no-longer-supported)
 - [`getSession` now returns a `Promise`](#getsession-now-returns-a-promise)
+- [Client methods and components are now exported under /client](#client-methods-and-components-are-now-exported-under-client)
 - [`updateSession` has been added](#updatesession-has-been-added)
 - [`getServerSidePropsWrapper` has been removed](#getserversidepropswrapper-has-been-removed)
 - [Profile API route no longer returns a 401](#profile-api-route-no-longer-returns-a-401)
@@ -42,6 +43,92 @@ async function myApiRoute(req, res) {
 }
 ```
 
+## Client methods and components are now exported under /client
+
+All methods and components for the browser should now be accessed under `/client`.
+
+### Before
+
+```js
+// pages/_app.js
+import React from 'react';
+import { UserProvider } from '@auth0/nextjs-auth0';
+
+export default function App({ Component, pageProps }) {
+  return (
+    <UserProvider>
+      <Component {...pageProps} />
+    </UserProvider>
+  );
+}
+```
+
+```js
+// pages/index.js
+import { useUser } from '@auth0/nextjs-auth0';
+
+export default function Index() {
+  const { user, error, isLoading } = useUser();
+
+  if (isLoading) return <div>Loading...</div>;
+  if (error) return <div>{error.message}</div>;
+
+  if (user) {
+    return (
+      <div>
+        Welcome {user.name}! <a href="/api/auth/logout">Logout</a>
+      </div>
+    );
+  }
+
+  return <a href="/api/auth/login">Login</a>;
+}
+```
+
+### After
+
+```js
+// pages/_app.js
+import React from 'react';
+import { UserProvider } from '@auth0/nextjs-auth0/client';
+
+export default function App({ Component, pageProps }) {
+  return (
+    <UserProvider>
+      <Component {...pageProps} />
+    </UserProvider>
+  );
+}
+```
+
+```js
+// pages/index.js
+import { useUser, withPageAuthRequired as withPageAuthRequiredCSR } from '@auth0/nextjs-auth0/client';
+// The SSR version of withPageAuthRequired is still in the root export
+import { withPageAuthRequired as withPageAuthRequiredSSR } from '@auth0/nextjs-auth0';
+
+export default withPageAuthRequiredCSR(function Index() {
+  const { user, error, isLoading } = useUser();
+
+  if (isLoading) return <div>Loading...</div>;
+  if (error) return <div>{error.message}</div>;
+
+  if (user) {
+    return (
+      <div>
+        Welcome {user.name}! <a href="/api/auth/logout">Logout</a>
+      </div>
+    );
+  }
+
+  return <a href="/api/auth/login">Login</a>;
+});
+
+export const getServerSideProps = withPageAuthRequiredSSR();
+```
+
+### Before
+
 ## `updateSession` has been added
 
 ### Before
diff --git a/client.d.ts b/client.d.ts
new file mode 100644
index 00000000..a2fd513e
--- /dev/null
+++ b/client.d.ts
@@ -0,0 +1,1 @@
+export type * from './dist/client';
diff --git a/client.js b/client.js
new file mode 100644
index 00000000..c9ae7295
--- /dev/null
+++ b/client.js
@@ -0,0 +1,1 @@
+module.exports = require('./dist/client');
diff --git a/edge.d.ts b/edge.d.ts
new file mode 100644
index 00000000..9b6b563c
--- /dev/null
+++ b/edge.d.ts
@@ -0,0 +1,1 @@
+export type * from './dist/edge';
diff --git a/edge.js b/edge.js
new file mode 100644
index 00000000..3fe72687
--- /dev/null
+++ b/edge.js
@@ -0,0 +1,1 @@
+module.exports = require('./dist/edge');
diff --git a/examples/basic-example/components/header.jsx b/examples/basic-example/components/header.jsx
index 99c575aa..086c0444 100644
--- a/examples/basic-example/components/header.jsx
+++ b/examples/basic-example/components/header.jsx
@@ -1,6 +1,6 @@
 import React from 'react';
 import Link from 'next/link';
-import { useUser } from '@auth0/nextjs-auth0';
+import { useUser } from '@auth0/nextjs-auth0/client';
 
 const Header = () => {
   const { user } = useUser();
diff --git a/examples/basic-example/pages/_app.jsx b/examples/basic-example/pages/_app.jsx
index ef83f2bd..a78730d7 100644
--- a/examples/basic-example/pages/_app.jsx
+++ b/examples/basic-example/pages/_app.jsx
@@ -1,5 +1,5 @@
 import React from 'react';
-import { UserProvider } from '@auth0/nextjs-auth0';
+import { UserProvider } from '@auth0/nextjs-auth0/client';
 
 export default function App({ Component, pageProps }) {
   // If you've used `withAuth`, pageProps.user can pre-populate the hook
diff --git a/examples/basic-example/pages/index.jsx b/examples/basic-example/pages/index.jsx
index be33daa8..9f80ea0d 100644
--- a/examples/basic-example/pages/index.jsx
+++ b/examples/basic-example/pages/index.jsx
@@ -1,5 +1,5 @@
 import React from 'react';
-import { useUser } from '@auth0/nextjs-auth0';
+import { useUser } from '@auth0/nextjs-auth0/client';
 
 import Layout from '../components/layout';
 
diff --git a/examples/basic-example/pages/protected-page.jsx b/examples/basic-example/pages/protected-page.jsx
index e2a056a8..89020d3a 100644
--- a/examples/basic-example/pages/protected-page.jsx
+++ b/examples/basic-example/pages/protected-page.jsx
@@ -1,5 +1,6 @@
 import React from 'react';
-import { useUser, withPageAuthRequired } from '@auth0/nextjs-auth0';
+import { withPageAuthRequired } from '@auth0/nextjs-auth0';
+import { useUser } from '@auth0/nextjs-auth0/client';
 
 import Layout from '../components/layout';
 
diff --git a/examples/kitchen-sink-example/.eslintrc b/examples/kitchen-sink-example/.eslintrc
index 1c4b377f..ece3c8be 100644
--- a/examples/kitchen-sink-example/.eslintrc
+++ b/examples/kitchen-sink-example/.eslintrc
@@ -5,8 +5,7 @@
     "eslint:recommended",
     "plugin:@typescript-eslint/eslint-recommended",
     "plugin:@typescript-eslint/recommended",
-    "plugin:import/recommended",
-    "plugin:react/recommended",
+    "plugin:@next/next/recommended",
     "plugin:prettier/recommended"
   ],
   "settings": {
diff --git a/examples/kitchen-sink-example/app/global.css b/examples/kitchen-sink-example/app/global.css
new file mode 100644
index 00000000..9d8c4229
--- /dev/null
+++ b/examples/kitchen-sink-example/app/global.css
@@ -0,0 +1,9 @@
+body {
+    margin: 0;
+    color: #333;
+    font-family: -apple-system, 'Segoe UI', sans-serif;
+}
+.container {
+    max-width: 42rem;
+    margin: 1.5rem auto;
+}
diff --git a/examples/kitchen-sink-example/app/head.tsx b/examples/kitchen-sink-example/app/head.tsx
new file mode 100644
index 00000000..df165251
--- /dev/null
+++ b/examples/kitchen-sink-example/app/head.tsx
@@ -0,0 +1,9 @@
+import React from 'react';
+
+export default function Head() {
+  return (
+    <>
+      <title>Next.js with Auth0</title>
+    </>
+  );
+}
diff --git a/examples/kitchen-sink-example/app/layout.tsx b/examples/kitchen-sink-example/app/layout.tsx
new file mode 100644
index 00000000..c7ade239
--- /dev/null
+++ b/examples/kitchen-sink-example/app/layout.tsx
@@ -0,0 +1,17 @@
+import React from 'react';
+import './global.css';
+import Header from '../components/header';
+import { UserProvider } from '@auth0/nextjs-auth0/client';
+
+export default function RootLayout({ children }: { children: React.ReactNode }) {
+  return (
+    <html lang="en">
+      <UserProvider>
+        <body>
+          <Header />
+          <div className="container">{children}</div>
+        </body>
+      </UserProvider>
+    </html>
+  );
+}
diff --git a/examples/kitchen-sink-example/app/profile-experimental-rsc/page.tsx b/examples/kitchen-sink-example/app/profile-experimental-rsc/page.tsx
new file mode 100644
index 00000000..7fec11ed
--- /dev/null
+++ b/examples/kitchen-sink-example/app/profile-experimental-rsc/page.tsx
@@ -0,0 +1,31 @@
+import { headers } from 'next/headers';
+import { getSession as auth0GetSession } from '@auth0/nextjs-auth0';
+import { IncomingMessage, ServerResponse } from 'http';
+import { Socket } from 'net';
+
+// Note: This is an experiment to test that the SDK works in the experimental app directory.
+// You should not rely on this code (or the app directory) in production.
+const reqRes = () => {
+  const req = new IncomingMessage(new Socket());
+  headers().forEach((v, k) => {
+    req.headers[k] = v;
+  });
+  const res = new ServerResponse(req);
+  return { req, res };
+};
+
+export function getSession() {
+  const { req, res } = reqRes();
+  return auth0GetSession(req, res);
+}
+
+export default async function ExperimentalRscPage() {
+  const session = await getSession();
+  return (
+    <div>
+      <h1>Profile</h1>
+      <h4>Profile</h4>
+      <pre>{JSON.stringify(session || {}, null, 2)}</pre>
+    </div>
+  );
+}
diff --git a/examples/kitchen-sink-example/components/header.tsx b/examples/kitchen-sink-example/components/header.tsx
index b61b1377..e18286d7 100644
--- a/examples/kitchen-sink-example/components/header.tsx
+++ b/examples/kitchen-sink-example/components/header.tsx
@@ -1,12 +1,13 @@
+'use client';
 import React from 'react';
 import Link from 'next/link';
-import { useUser } from '@auth0/nextjs-auth0';
+import { useUser } from '@auth0/nextjs-auth0/client';
 
 const Header = (): React.ReactElement => {
   const { user } = useUser();
 
   return (
-    <header>
+    <div id="header">
       <nav>
         <ul>
           <li>
@@ -32,7 +33,19 @@ const Header = (): React.ReactElement => {
                 </Link>
               </li>{' '}
               <li>
-                <a href="/profile-ssr">Profile (SSR)</a>
+                <Link href="/profile-ssr" legacyBehavior>
+                  <a>Profile (SSR)</a>
+                </Link>
+              </li>{' '}
+              <li>
+                <Link href="/profile-mw" legacyBehavior>
+                  <a>Profile (MW)</a>
+                </Link>
+              </li>{' '}
+              <li>
+                <Link href="/profile-experimental-rsc" legacyBehavior>
+                  <a>Profile (Experimental RSC)</a>
+                </Link>
               </li>{' '}
               <li>
                 <a href="/api/auth/logout" data-testid="logout">
@@ -41,19 +54,17 @@ const Header = (): React.ReactElement => {
               </li>
             </>
           ) : (
-            <>
-              <li>
-                <a href="/api/auth/login" data-testid="login">
-                  Login
-                </a>
-              </li>
-            </>
+            <li>
+              <a href="/api/auth/login" data-testid="login">
+                Login
+              </a>
+            </li>
           )}
         </ul>
       </nav>
 
       <style jsx>{`
-        header {
+        #header {
           padding: 0.2rem;
           color: #fff;
           background-color: #333;
@@ -86,7 +97,7 @@ const Header = (): React.ReactElement => {
           background: none;
         }
       `}</style>
-    </header>
+    </div>
   );
 };
 
diff --git a/examples/kitchen-sink-example/middleware.ts b/examples/kitchen-sink-example/middleware.ts
index dd66b96d..fb2930b0 100644
--- a/examples/kitchen-sink-example/middleware.ts
+++ b/examples/kitchen-sink-example/middleware.ts
@@ -1,4 +1,4 @@
-import { withMiddlewareAuthRequired } from '@auth0/nextjs-auth0/middleware';
+import { withMiddlewareAuthRequired } from '@auth0/nextjs-auth0/edge';
 
 export default withMiddlewareAuthRequired();
 
diff --git a/examples/kitchen-sink-example/next.config.js b/examples/kitchen-sink-example/next.config.js
index 4f336cb7..cae4f577 100644
--- a/examples/kitchen-sink-example/next.config.js
+++ b/examples/kitchen-sink-example/next.config.js
@@ -1,3 +1,6 @@
 module.exports = {
-  poweredByHeader: false
+  poweredByHeader: false,
+  experimental: {
+    appDir: true
+  }
 };
diff --git a/examples/kitchen-sink-example/package.json b/examples/kitchen-sink-example/package.json
index 0fad45d1..e65db4a1 100644
--- a/examples/kitchen-sink-example/package.json
+++ b/examples/kitchen-sink-example/package.json
@@ -20,16 +20,15 @@
     "eslint"
   ],
   "devDependencies": {
+    "@next/eslint-plugin-next": "^13.0.3",
     "@types/node": "^14.14.21",
-    "@types/react": "^17.0.0",
+    "@types/react": "^18.0.25",
     "@types/styled-jsx": "^3.4.4",
     "@typescript-eslint/eslint-plugin": "^4.13.0",
     "@typescript-eslint/parser": "^4.13.0",
     "eslint": "^7.9.0",
     "eslint-config-prettier": "^8.1.0",
-    "eslint-plugin-import": "^2.22.0",
     "eslint-plugin-prettier": "^3.1.4",
-    "eslint-plugin-react": "^7.20.6",
     "express": "^4.17.1",
     "lint-staged": "^10.3.0",
     "prettier": "^2.1.1",
diff --git a/examples/kitchen-sink-example/pages/_app.tsx b/examples/kitchen-sink-example/pages/_app.tsx
index 1a7f5b52..b42124c0 100644
--- a/examples/kitchen-sink-example/pages/_app.tsx
+++ b/examples/kitchen-sink-example/pages/_app.tsx
@@ -1,6 +1,6 @@
 import React from 'react';
 import type { AppProps } from 'next/app';
-import { UserProvider } from '@auth0/nextjs-auth0';
+import { UserProvider } from '@auth0/nextjs-auth0/client';
 
 export default function App({ Component, pageProps }: AppProps): React.ReactElement<AppProps> {
   const { user } = pageProps;
diff --git a/examples/kitchen-sink-example/pages/index.tsx b/examples/kitchen-sink-example/pages/index.tsx
index 0c077bc2..e7287dd4 100644
--- a/examples/kitchen-sink-example/pages/index.tsx
+++ b/examples/kitchen-sink-example/pages/index.tsx
@@ -1,5 +1,5 @@
 import React from 'react';
-import { useUser } from '@auth0/nextjs-auth0';
+import { useUser } from '@auth0/nextjs-auth0/client';
 
 import Layout from '../components/layout';
 
diff --git a/examples/kitchen-sink-example/pages/profile-mw.tsx b/examples/kitchen-sink-example/pages/profile-mw.tsx
index 2d6aaed5..9f17f546 100644
--- a/examples/kitchen-sink-example/pages/profile-mw.tsx
+++ b/examples/kitchen-sink-example/pages/profile-mw.tsx
@@ -1,5 +1,5 @@
 import React from 'react';
-import { useUser } from '@auth0/nextjs-auth0';
+import { useUser } from '@auth0/nextjs-auth0/client';
 
 import Layout from '../components/layout';
 
diff --git a/examples/kitchen-sink-example/pages/profile-ssr.tsx b/examples/kitchen-sink-example/pages/profile-ssr.tsx
index 872a44f5..839ce240 100644
--- a/examples/kitchen-sink-example/pages/profile-ssr.tsx
+++ b/examples/kitchen-sink-example/pages/profile-ssr.tsx
@@ -1,5 +1,6 @@
 import React from 'react';
-import { UserProfile, withPageAuthRequired } from '@auth0/nextjs-auth0';
+import { withPageAuthRequired } from '@auth0/nextjs-auth0';
+import { UserProfile } from '@auth0/nextjs-auth0/client';
 
 import Layout from '../components/layout';
 
diff --git a/examples/kitchen-sink-example/pages/profile.tsx b/examples/kitchen-sink-example/pages/profile.tsx
index 9f03f422..e40ef153 100644
--- a/examples/kitchen-sink-example/pages/profile.tsx
+++ b/examples/kitchen-sink-example/pages/profile.tsx
@@ -1,5 +1,5 @@
 import React from 'react';
-import { withPageAuthRequired } from '@auth0/nextjs-auth0';
+import { withPageAuthRequired } from '@auth0/nextjs-auth0/client';
 
 import Layout from '../components/layout';
 
diff --git a/examples/kitchen-sink-example/pages/shows.tsx b/examples/kitchen-sink-example/pages/shows.tsx
index 3178849e..ed36edce 100644
--- a/examples/kitchen-sink-example/pages/shows.tsx
+++ b/examples/kitchen-sink-example/pages/shows.tsx
@@ -2,7 +2,7 @@ import React from 'react';
 
 import useApi from '../lib/use-api';
 import Layout from '../components/layout';
-import { withPageAuthRequired } from '@auth0/nextjs-auth0';
+import { withPageAuthRequired } from '@auth0/nextjs-auth0/client';
 
 type TVShow = { show: { name: string } };
 
diff --git a/examples/kitchen-sink-example/tsconfig.json b/examples/kitchen-sink-example/tsconfig.json
index 1aae97f3..50eb114d 100644
--- a/examples/kitchen-sink-example/tsconfig.json
+++ b/examples/kitchen-sink-example/tsconfig.json
@@ -17,12 +17,18 @@
     "resolveJsonModule": true,
     "jsx": "preserve",
     "isolatedModules": true,
-    "incremental": true
+    "incremental": true,
+    "plugins": [
+      {
+        "name": "next"
+      }
+    ]
   },
   "include": [
     "next-env.d.ts",
     "**/*.ts",
-    "**/*.tsx"
+    "**/*.tsx",
+    ".next/types/**/*.ts"
   ],
   "exclude": [
     "node_modules"
diff --git a/middleware.d.ts b/middleware.d.ts
deleted file mode 100644
index f0d69b8f..00000000
--- a/middleware.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import type { WithMiddlewareAuthRequired, GetSession, InitAuth0 } from './dist/middleware';
-
-export declare const initAuth0: InitAuth0;
-export declare const getSession: GetSession;
-export declare const withMiddlewareAuthRequired: WithMiddlewareAuthRequired;
diff --git a/middleware.js b/middleware.js
deleted file mode 100644
index e5396c61..00000000
--- a/middleware.js
+++ /dev/null
@@ -1,1 +0,0 @@
-module.exports = require('./dist/middleware');
diff --git a/package-lock.json b/package-lock.json
index eb38eb6e..a745db23 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -45,14 +45,14 @@
         "cypress": "^8.4.0",
         "eslint": "^7.17.0",
         "eslint-config-prettier": "^8.1.0",
-        "eslint-import-resolver-typescript": "^2.3.0",
+        "eslint-import-resolver-typescript": "^3.5.2",
         "eslint-plugin-import": "^2.22.1",
         "eslint-plugin-jsx-a11y": "^6.4.1",
         "eslint-plugin-prettier": "^3.3.1",
         "eslint-plugin-react": "^7.22.0",
         "eslint-plugin-react-hooks": "^4.2.0",
         "jest": "^27.2.0",
-        "next": "^13.0.1",
+        "next": "^13.0.3",
         "nock": "^13.0.5",
         "oidc-provider": "^7.6.0",
         "on-headers": "^1.0.2",
@@ -1784,15 +1784,15 @@
       }
     },
     "node_modules/@next/env": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/env/-/env-13.0.1.tgz",
-      "integrity": "sha512-gK60YoFae3s8qi5UgIzbvxOhsh5gKyEaiKH5+kLBUYXLlrPyWJR2xKBj2WqvHkO7wDX7/Hed3DAqjSpU4ijIvQ==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/env/-/env-13.0.3.tgz",
+      "integrity": "sha512-/4WzeG61Ot/PxsghXkSqQJ6UohFfwXoZ3dtsypmR9EBP+OIax9JRq0trq8Z/LCT9Aq4JbihVkaazRWguORjTAw==",
       "dev": true
     },
     "node_modules/@next/swc-android-arm-eabi": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.0.1.tgz",
-      "integrity": "sha512-M28QSbohZlNXNn//HY6lV2T3YaMzG58Jwr0YwOdVmOQv6i+7lu6xe3GqQu4kdqInqhLrBXnL+nabFuGTVSHtTg==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.0.3.tgz",
+      "integrity": "sha512-uxfUoj65CdFc1gX2q7GtBX3DhKv9Kn343LMqGNvXyuTpYTGMmIiVY7b9yF8oLWRV0gVKqhZBZifUmoPE8SJU6Q==",
       "cpu": [
         "arm"
       ],
@@ -1806,9 +1806,9 @@
       }
     },
     "node_modules/@next/swc-android-arm64": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.0.1.tgz",
-      "integrity": "sha512-szmO/i6GoHcPXcbhUKhwBMETWHNXH3ITz9wfxwOOFBNKdDU8pjKsHL88lg28aOiQYZSU1sxu1v1p9KY5kJIZCg==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.0.3.tgz",
+      "integrity": "sha512-t2k+WDfg7Cq2z/EnalKGsd/9E5F4Hdo1xu+UzZXYDpKUI9zgE6Bz8ajQb8m8txv3qOaWdKuDa5j5ziq9Acd1Xw==",
       "cpu": [
         "arm64"
       ],
@@ -1822,9 +1822,9 @@
       }
     },
     "node_modules/@next/swc-darwin-arm64": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.0.1.tgz",
-      "integrity": "sha512-O1RxCaiDNOjGZmdAp6SQoHUITt9aVDQXoR3lZ/TloI/NKRAyAV4u0KUUofK+KaZeHOmVTnPUaQuCyZSc3i1x5Q==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.0.3.tgz",
+      "integrity": "sha512-wV6j6SZ1bc/YHOLCLk9JVqaZTCCey6HBV7inl2DriHsHqIcO6F3+QiYf0KXwRP9BE0GSZZrYd5mZQm2JPTHdJA==",
       "cpu": [
         "arm64"
       ],
@@ -1838,9 +1838,9 @@
       }
     },
     "node_modules/@next/swc-darwin-x64": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.0.1.tgz",
-      "integrity": "sha512-8E6BY/VO+QqQkthhoWgB8mJMw1NcN9Vhl2OwEwxv8jy2r3zjeU+WNRxz4y8RLbcY0R1h+vHlXuP0mLnuac84tQ==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.0.3.tgz",
+      "integrity": "sha512-jaI2CMuYWvUtRixV3AIjUhnxUDU1FKOR+8hADMhYt3Yz+pCKuj4RZ0n0nY5qUf3qT1AtvnJXEgyatSFJhSp/wQ==",
       "cpu": [
         "x64"
       ],
@@ -1854,9 +1854,9 @@
       }
     },
     "node_modules/@next/swc-freebsd-x64": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.0.1.tgz",
-      "integrity": "sha512-ocwoOxm2KVwF50RyoAT+2RQPLlkyoF7sAqzMUVgj+S6+DTkY3iwH+Zpo0XAk2pnqT9qguOrKnEpq9EIx//+K7Q==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.0.3.tgz",
+      "integrity": "sha512-nbyT0toBTJrcj5TCB9pVnQpGJ3utGyQj4CWegZs1ulaeUQ5Z7CS/qt8nRyYyOKYHtOdSCJ9Nw5F/RgKNkdpOdw==",
       "cpu": [
         "x64"
       ],
@@ -1870,9 +1870,9 @@
       }
     },
     "node_modules/@next/swc-linux-arm-gnueabihf": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.0.1.tgz",
-      "integrity": "sha512-yO7e3zITfGol/N6lPQnmIRi0WyuILBMXrvH6EdmWzzqMDJFfTCII6l+B6gMO5WVDCTQUGQlQRNZ7sFqWR4I71g==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.0.3.tgz",
+      "integrity": "sha512-1naLxYvRUQCoFCU1nMkcQueRc0Iux9xBv1L5pzH2ejtIWFg8BrSgyuluJG4nyAhFCx4WG863IEIkAaefOowVdA==",
       "cpu": [
         "arm"
       ],
@@ -1886,9 +1886,9 @@
       }
     },
     "node_modules/@next/swc-linux-arm64-gnu": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.0.1.tgz",
-      "integrity": "sha512-OEs6WDPDI8RyM8SjOqTDMqMBfOlU97VnW6ZMXUvzUTyH0K9c7NF+cn7UMu+I4tKFN0uJ9WQs/6TYaFBGkgoVVA==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.0.3.tgz",
+      "integrity": "sha512-3Z4A8JkuGWpMVbUhUPQInK/SLY+kijTT78Q/NZCrhLlyvwrVxaQALJNlXzxDLraUgv4oVH0Wz/FIw1W9PUUhxA==",
       "cpu": [
         "arm64"
       ],
@@ -1902,9 +1902,9 @@
       }
     },
     "node_modules/@next/swc-linux-arm64-musl": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.0.1.tgz",
-      "integrity": "sha512-y5ypFK0Y3urZSFoQxbtDqvKsBx026sz+Fm+xHlPWlGHNZrbs3Q812iONjcZTo09QwRMk5X86iMWBRxV18xMhaw==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.0.3.tgz",
+      "integrity": "sha512-MoYe9SM40UaunTjC+01c9OILLH3uSoeri58kDMu3KF/EFEvn1LZ6ODeDj+SLGlAc95wn46hrRJS2BPmDDE+jFQ==",
       "cpu": [
         "arm64"
       ],
@@ -1918,9 +1918,9 @@
       }
     },
     "node_modules/@next/swc-linux-x64-gnu": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.0.1.tgz",
-      "integrity": "sha512-XDIHEE6SU8VCF+dUVntD6PDv6RK31N0forx9kucZBYirbe8vCZ+Yx8hYgvtIaGrTcWtGxibxmND0pIuHDq8H5g==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.0.3.tgz",
+      "integrity": "sha512-z22T5WGnRanjLMXdF0NaNjSpBlEzzY43t5Ysp3nW1oI6gOkub6WdQNZeHIY7A2JwkgSWZmtjLtf+Fzzz38LHeQ==",
       "cpu": [
         "x64"
       ],
@@ -1934,9 +1934,9 @@
       }
     },
     "node_modules/@next/swc-linux-x64-musl": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.0.1.tgz",
-      "integrity": "sha512-yxIOuuz5EOx0F1FDtsyzaLgnDym0Ysxv8CWeJyDTKKmt9BVyITg6q/cD+RP9bEkT1TQi+PYXIMATSz675Q82xw==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.0.3.tgz",
+      "integrity": "sha512-ZOMT7zjBFmkusAtr47k8xs/oTLsNlTH6xvYb+iux7yly2hZGwhfBLzPGBsbeMZukZ96IphJTagT+C033s6LNVA==",
       "cpu": [
         "x64"
       ],
@@ -1950,9 +1950,9 @@
       }
     },
     "node_modules/@next/swc-win32-arm64-msvc": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.0.1.tgz",
-      "integrity": "sha512-+ucLe2qgQzP+FM94jD4ns6LDGyMFaX9k3lVHqu/tsQCy2giMymbport4y4p77mYcXEMlDaHMzlHgOQyHRniWFA==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.0.3.tgz",
+      "integrity": "sha512-Q4BM16Djl+Oah9UdGrvjFYgoftYB2jNd+rtRGPX5Mmxo09Ry/KiLbOZnoUyoIxKc1xPyfqMXuaVsAFQLYs0KEQ==",
       "cpu": [
         "arm64"
       ],
@@ -1966,9 +1966,9 @@
       }
     },
     "node_modules/@next/swc-win32-ia32-msvc": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.0.1.tgz",
-      "integrity": "sha512-Krr/qGN7OB35oZuvMAZKoXDt2IapynIWLh5A5rz6AODb7f/ZJqyAuZSK12vOa2zKdobS36Qm4IlxxBqn9c00MA==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.0.3.tgz",
+      "integrity": "sha512-Sa8yGkNeRUsic8Qjf7MLIAfP0p0+einK/wIqJ8UO1y76j+8rRQu42AMs5H4Ax1fm9GEYq6I8njHtY59TVpTtGQ==",
       "cpu": [
         "ia32"
       ],
@@ -1982,9 +1982,9 @@
       }
     },
     "node_modules/@next/swc-win32-x64-msvc": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.0.1.tgz",
-      "integrity": "sha512-t/0G33t/6VGWZUGCOT7rG42qqvf/x+MrFp1CU+8CN6PrjSSL57R5bqkXfubV9t4eCEnUxVP+5Hn3MoEXEebtEw==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.0.3.tgz",
+      "integrity": "sha512-IAptmSqA7k4tQzaw2NAkoEjj3+Dz9ceuvlEHwYh770MMDL4V0ku2m+UHrmn5HUCEDHhgwwjg2nyf6728q2jr1w==",
       "cpu": [
         "x64"
       ],
@@ -2040,6 +2040,26 @@
         "url": "https://github.com/sponsors/panva"
       }
     },
+    "node_modules/@pkgr/utils": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.3.1.tgz",
+      "integrity": "sha512-wfzX8kc1PMyUILA+1Z/EqoE4UCXGy0iRGMhPwdfae1+f0OXlLqCk+By+aMzgJBzR9AzS4CDizioG6Ss1gvAFJw==",
+      "dev": true,
+      "dependencies": {
+        "cross-spawn": "^7.0.3",
+        "is-glob": "^4.0.3",
+        "open": "^8.4.0",
+        "picocolors": "^1.0.0",
+        "tiny-glob": "^0.2.9",
+        "tslib": "^2.4.0"
+      },
+      "engines": {
+        "node": "^12.20.0 || ^14.18.0 || >=16.0.0"
+      },
+      "funding": {
+        "url": "https://opencollective.com/unts"
+      }
+    },
     "node_modules/@sideway/address": {
       "version": "4.1.3",
       "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.3.tgz",
@@ -5080,6 +5100,15 @@
         "node": ">=10"
       }
     },
+    "node_modules/define-lazy-prop": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz",
+      "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==",
+      "dev": true,
+      "engines": {
+        "node": ">=8"
+      }
+    },
     "node_modules/define-properties": {
       "version": "1.1.4",
       "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz",
@@ -5313,6 +5342,19 @@
         "once": "^1.4.0"
       }
     },
+    "node_modules/enhanced-resolve": {
+      "version": "5.10.0",
+      "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz",
+      "integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==",
+      "dev": true,
+      "dependencies": {
+        "graceful-fs": "^4.2.4",
+        "tapable": "^2.2.0"
+      },
+      "engines": {
+        "node": ">=10.13.0"
+      }
+    },
     "node_modules/enquirer": {
       "version": "2.3.6",
       "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
@@ -5626,25 +5668,70 @@
       }
     },
     "node_modules/eslint-import-resolver-typescript": {
-      "version": "2.7.1",
-      "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.7.1.tgz",
-      "integrity": "sha512-00UbgGwV8bSgUv34igBDbTOtKhqoRMy9bFjNehT40bXg6585PNIct8HhXZ0SybqB9rWtXj9crcku8ndDn/gIqQ==",
+      "version": "3.5.2",
+      "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.5.2.tgz",
+      "integrity": "sha512-zX4ebnnyXiykjhcBvKIf5TNvt8K7yX6bllTRZ14MiurKPjDpCAZujlszTdB8pcNXhZcOf+god4s9SjQa5GnytQ==",
       "dev": true,
       "dependencies": {
         "debug": "^4.3.4",
-        "glob": "^7.2.0",
+        "enhanced-resolve": "^5.10.0",
+        "get-tsconfig": "^4.2.0",
+        "globby": "^13.1.2",
+        "is-core-module": "^2.10.0",
         "is-glob": "^4.0.3",
-        "resolve": "^1.22.0",
-        "tsconfig-paths": "^3.14.1"
+        "synckit": "^0.8.4"
       },
       "engines": {
-        "node": ">=4"
+        "node": "^14.18.0 || >=16.0.0"
+      },
+      "funding": {
+        "url": "https://opencollective.com/unts/projects/eslint-import-resolver-ts"
       },
       "peerDependencies": {
         "eslint": "*",
         "eslint-plugin-import": "*"
       }
     },
+    "node_modules/eslint-import-resolver-typescript/node_modules/globby": {
+      "version": "13.1.2",
+      "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz",
+      "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==",
+      "dev": true,
+      "dependencies": {
+        "dir-glob": "^3.0.1",
+        "fast-glob": "^3.2.11",
+        "ignore": "^5.2.0",
+        "merge2": "^1.4.1",
+        "slash": "^4.0.0"
+      },
+      "engines": {
+        "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
+    "node_modules/eslint-import-resolver-typescript/node_modules/ignore": {
+      "version": "5.2.0",
+      "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
+      "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
+      "dev": true,
+      "engines": {
+        "node": ">= 4"
+      }
+    },
+    "node_modules/eslint-import-resolver-typescript/node_modules/slash": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
+      "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==",
+      "dev": true,
+      "engines": {
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
     "node_modules/eslint-module-utils": {
       "version": "2.7.3",
       "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz",
@@ -6647,6 +6734,15 @@
         "url": "https://github.com/sponsors/ljharb"
       }
     },
+    "node_modules/get-tsconfig": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.2.0.tgz",
+      "integrity": "sha512-X8u8fREiYOE6S8hLbq99PeykTDoLVnxvF4DjWKJmz9xy2nNRdUcV8ZN9tniJFeKyTU3qnC9lL8n4Chd6LmVKHg==",
+      "dev": true,
+      "funding": {
+        "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
+      }
+    },
     "node_modules/getmac": {
       "version": "5.20.0",
       "resolved": "https://registry.npmjs.org/getmac/-/getmac-5.20.0.tgz",
@@ -6748,6 +6844,12 @@
         "url": "https://github.com/sponsors/sindresorhus"
       }
     },
+    "node_modules/globalyzer": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
+      "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==",
+      "dev": true
+    },
     "node_modules/globby": {
       "version": "11.1.0",
       "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
@@ -6777,6 +6879,12 @@
         "node": ">= 4"
       }
     },
+    "node_modules/globrex": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
+      "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==",
+      "dev": true
+    },
     "node_modules/got": {
       "version": "11.8.5",
       "resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz",
@@ -7279,9 +7387,9 @@
       }
     },
     "node_modules/is-core-module": {
-      "version": "2.9.0",
-      "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",
-      "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",
+      "version": "2.11.0",
+      "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",
+      "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
       "dev": true,
       "dependencies": {
         "has": "^1.0.3"
@@ -7302,6 +7410,21 @@
         "url": "https://github.com/sponsors/ljharb"
       }
     },
+    "node_modules/is-docker": {
+      "version": "2.2.1",
+      "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
+      "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
+      "dev": true,
+      "bin": {
+        "is-docker": "cli.js"
+      },
+      "engines": {
+        "node": ">=8"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
     "node_modules/is-extglob": {
       "version": "2.1.1",
       "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -7609,6 +7732,18 @@
         "url": "https://github.com/sponsors/ljharb"
       }
     },
+    "node_modules/is-wsl": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
+      "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
+      "dev": true,
+      "dependencies": {
+        "is-docker": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
     "node_modules/is-yarn-global": {
       "version": "0.3.0",
       "resolved": "https://registry.npmjs.org/is-yarn-global/-/is-yarn-global-0.3.0.tgz",
@@ -10704,12 +10839,12 @@
       "dev": true
     },
     "node_modules/next": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/next/-/next-13.0.1.tgz",
-      "integrity": "sha512-ErCNBPIeZMKFn6hX+ZBSlqZVgJIeitEqhGTuQUNmYXJ07/A71DZ7AJI8eyHYUdBb686LUpV1/oBdTq9RpzRVPg==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/next/-/next-13.0.3.tgz",
+      "integrity": "sha512-rFQeepcenRxKzeKlh1CsmEnxsJwhIERtbUjmYnKZyDInZsU06lvaGw5DT44rlNp1Rv2MT/e9vffZ8vK+ytwXHA==",
       "dev": true,
       "dependencies": {
-        "@next/env": "13.0.1",
+        "@next/env": "13.0.3",
         "@swc/helpers": "0.4.11",
         "caniuse-lite": "^1.0.30001406",
         "postcss": "8.4.14",
@@ -10723,19 +10858,19 @@
         "node": ">=14.6.0"
       },
       "optionalDependencies": {
-        "@next/swc-android-arm-eabi": "13.0.1",
-        "@next/swc-android-arm64": "13.0.1",
-        "@next/swc-darwin-arm64": "13.0.1",
-        "@next/swc-darwin-x64": "13.0.1",
-        "@next/swc-freebsd-x64": "13.0.1",
-        "@next/swc-linux-arm-gnueabihf": "13.0.1",
-        "@next/swc-linux-arm64-gnu": "13.0.1",
-        "@next/swc-linux-arm64-musl": "13.0.1",
-        "@next/swc-linux-x64-gnu": "13.0.1",
-        "@next/swc-linux-x64-musl": "13.0.1",
-        "@next/swc-win32-arm64-msvc": "13.0.1",
-        "@next/swc-win32-ia32-msvc": "13.0.1",
-        "@next/swc-win32-x64-msvc": "13.0.1"
+        "@next/swc-android-arm-eabi": "13.0.3",
+        "@next/swc-android-arm64": "13.0.3",
+        "@next/swc-darwin-arm64": "13.0.3",
+        "@next/swc-darwin-x64": "13.0.3",
+        "@next/swc-freebsd-x64": "13.0.3",
+        "@next/swc-linux-arm-gnueabihf": "13.0.3",
+        "@next/swc-linux-arm64-gnu": "13.0.3",
+        "@next/swc-linux-arm64-musl": "13.0.3",
+        "@next/swc-linux-x64-gnu": "13.0.3",
+        "@next/swc-linux-x64-musl": "13.0.3",
+        "@next/swc-win32-arm64-msvc": "13.0.3",
+        "@next/swc-win32-ia32-msvc": "13.0.3",
+        "@next/swc-win32-x64-msvc": "13.0.3"
       },
       "peerDependencies": {
         "fibers": ">= 3.1.0",
@@ -11110,6 +11245,23 @@
       "integrity": "sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=",
       "dev": true
     },
+    "node_modules/open": {
+      "version": "8.4.0",
+      "resolved": "https://registry.npmjs.org/open/-/open-8.4.0.tgz",
+      "integrity": "sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==",
+      "dev": true,
+      "dependencies": {
+        "define-lazy-prop": "^2.0.0",
+        "is-docker": "^2.1.1",
+        "is-wsl": "^2.2.0"
+      },
+      "engines": {
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
     "node_modules/openid-client": {
       "version": "5.2.1",
       "resolved": "https://registry.npmjs.org/openid-client/-/openid-client-5.2.1.tgz",
@@ -12978,6 +13130,22 @@
       "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
       "dev": true
     },
+    "node_modules/synckit": {
+      "version": "0.8.4",
+      "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.4.tgz",
+      "integrity": "sha512-Dn2ZkzMdSX827QbowGbU/4yjWuvNaCoScLLoMo/yKbu+P4GBR6cRGKZH27k6a9bRzdqcyd1DE96pQtQ6uNkmyw==",
+      "dev": true,
+      "dependencies": {
+        "@pkgr/utils": "^2.3.1",
+        "tslib": "^2.4.0"
+      },
+      "engines": {
+        "node": "^14.18.0 || >=16.0.0"
+      },
+      "funding": {
+        "url": "https://opencollective.com/unts"
+      }
+    },
     "node_modules/table": {
       "version": "6.8.0",
       "resolved": "https://registry.npmjs.org/table/-/table-6.8.0.tgz",
@@ -13033,6 +13201,15 @@
         "url": "https://github.com/chalk/slice-ansi?sponsor=1"
       }
     },
+    "node_modules/tapable": {
+      "version": "2.2.1",
+      "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
+      "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=6"
+      }
+    },
     "node_modules/tar-stream": {
       "version": "2.2.0",
       "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
@@ -13147,6 +13324,16 @@
       "integrity": "sha512-W3AmPTJWZkRwu+iSNxPIsLZ2ByADsOLbbLxe46UJyWj3mlYLlwucKiq+/dPm0l9wTzqoF3/2PH0AGFCebjq23A==",
       "dev": true
     },
+    "node_modules/tiny-glob": {
+      "version": "0.2.9",
+      "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
+      "integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
+      "dev": true,
+      "dependencies": {
+        "globalyzer": "0.1.0",
+        "globrex": "^0.1.2"
+      }
+    },
     "node_modules/tmp": {
       "version": "0.2.1",
       "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
@@ -15549,99 +15736,99 @@
       }
     },
     "@next/env": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/env/-/env-13.0.1.tgz",
-      "integrity": "sha512-gK60YoFae3s8qi5UgIzbvxOhsh5gKyEaiKH5+kLBUYXLlrPyWJR2xKBj2WqvHkO7wDX7/Hed3DAqjSpU4ijIvQ==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/env/-/env-13.0.3.tgz",
+      "integrity": "sha512-/4WzeG61Ot/PxsghXkSqQJ6UohFfwXoZ3dtsypmR9EBP+OIax9JRq0trq8Z/LCT9Aq4JbihVkaazRWguORjTAw==",
       "dev": true
     },
     "@next/swc-android-arm-eabi": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.0.1.tgz",
-      "integrity": "sha512-M28QSbohZlNXNn//HY6lV2T3YaMzG58Jwr0YwOdVmOQv6i+7lu6xe3GqQu4kdqInqhLrBXnL+nabFuGTVSHtTg==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.0.3.tgz",
+      "integrity": "sha512-uxfUoj65CdFc1gX2q7GtBX3DhKv9Kn343LMqGNvXyuTpYTGMmIiVY7b9yF8oLWRV0gVKqhZBZifUmoPE8SJU6Q==",
       "dev": true,
       "optional": true
     },
     "@next/swc-android-arm64": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.0.1.tgz",
-      "integrity": "sha512-szmO/i6GoHcPXcbhUKhwBMETWHNXH3ITz9wfxwOOFBNKdDU8pjKsHL88lg28aOiQYZSU1sxu1v1p9KY5kJIZCg==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.0.3.tgz",
+      "integrity": "sha512-t2k+WDfg7Cq2z/EnalKGsd/9E5F4Hdo1xu+UzZXYDpKUI9zgE6Bz8ajQb8m8txv3qOaWdKuDa5j5ziq9Acd1Xw==",
       "dev": true,
       "optional": true
     },
     "@next/swc-darwin-arm64": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.0.1.tgz",
-      "integrity": "sha512-O1RxCaiDNOjGZmdAp6SQoHUITt9aVDQXoR3lZ/TloI/NKRAyAV4u0KUUofK+KaZeHOmVTnPUaQuCyZSc3i1x5Q==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.0.3.tgz",
+      "integrity": "sha512-wV6j6SZ1bc/YHOLCLk9JVqaZTCCey6HBV7inl2DriHsHqIcO6F3+QiYf0KXwRP9BE0GSZZrYd5mZQm2JPTHdJA==",
       "dev": true,
       "optional": true
     },
     "@next/swc-darwin-x64": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.0.1.tgz",
-      "integrity": "sha512-8E6BY/VO+QqQkthhoWgB8mJMw1NcN9Vhl2OwEwxv8jy2r3zjeU+WNRxz4y8RLbcY0R1h+vHlXuP0mLnuac84tQ==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.0.3.tgz",
+      "integrity": "sha512-jaI2CMuYWvUtRixV3AIjUhnxUDU1FKOR+8hADMhYt3Yz+pCKuj4RZ0n0nY5qUf3qT1AtvnJXEgyatSFJhSp/wQ==",
       "dev": true,
       "optional": true
     },
     "@next/swc-freebsd-x64": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.0.1.tgz",
-      "integrity": "sha512-ocwoOxm2KVwF50RyoAT+2RQPLlkyoF7sAqzMUVgj+S6+DTkY3iwH+Zpo0XAk2pnqT9qguOrKnEpq9EIx//+K7Q==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.0.3.tgz",
+      "integrity": "sha512-nbyT0toBTJrcj5TCB9pVnQpGJ3utGyQj4CWegZs1ulaeUQ5Z7CS/qt8nRyYyOKYHtOdSCJ9Nw5F/RgKNkdpOdw==",
       "dev": true,
       "optional": true
     },
     "@next/swc-linux-arm-gnueabihf": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.0.1.tgz",
-      "integrity": "sha512-yO7e3zITfGol/N6lPQnmIRi0WyuILBMXrvH6EdmWzzqMDJFfTCII6l+B6gMO5WVDCTQUGQlQRNZ7sFqWR4I71g==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.0.3.tgz",
+      "integrity": "sha512-1naLxYvRUQCoFCU1nMkcQueRc0Iux9xBv1L5pzH2ejtIWFg8BrSgyuluJG4nyAhFCx4WG863IEIkAaefOowVdA==",
       "dev": true,
       "optional": true
     },
     "@next/swc-linux-arm64-gnu": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.0.1.tgz",
-      "integrity": "sha512-OEs6WDPDI8RyM8SjOqTDMqMBfOlU97VnW6ZMXUvzUTyH0K9c7NF+cn7UMu+I4tKFN0uJ9WQs/6TYaFBGkgoVVA==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.0.3.tgz",
+      "integrity": "sha512-3Z4A8JkuGWpMVbUhUPQInK/SLY+kijTT78Q/NZCrhLlyvwrVxaQALJNlXzxDLraUgv4oVH0Wz/FIw1W9PUUhxA==",
       "dev": true,
       "optional": true
     },
     "@next/swc-linux-arm64-musl": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.0.1.tgz",
-      "integrity": "sha512-y5ypFK0Y3urZSFoQxbtDqvKsBx026sz+Fm+xHlPWlGHNZrbs3Q812iONjcZTo09QwRMk5X86iMWBRxV18xMhaw==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.0.3.tgz",
+      "integrity": "sha512-MoYe9SM40UaunTjC+01c9OILLH3uSoeri58kDMu3KF/EFEvn1LZ6ODeDj+SLGlAc95wn46hrRJS2BPmDDE+jFQ==",
       "dev": true,
       "optional": true
     },
     "@next/swc-linux-x64-gnu": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.0.1.tgz",
-      "integrity": "sha512-XDIHEE6SU8VCF+dUVntD6PDv6RK31N0forx9kucZBYirbe8vCZ+Yx8hYgvtIaGrTcWtGxibxmND0pIuHDq8H5g==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.0.3.tgz",
+      "integrity": "sha512-z22T5WGnRanjLMXdF0NaNjSpBlEzzY43t5Ysp3nW1oI6gOkub6WdQNZeHIY7A2JwkgSWZmtjLtf+Fzzz38LHeQ==",
       "dev": true,
       "optional": true
     },
     "@next/swc-linux-x64-musl": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.0.1.tgz",
-      "integrity": "sha512-yxIOuuz5EOx0F1FDtsyzaLgnDym0Ysxv8CWeJyDTKKmt9BVyITg6q/cD+RP9bEkT1TQi+PYXIMATSz675Q82xw==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.0.3.tgz",
+      "integrity": "sha512-ZOMT7zjBFmkusAtr47k8xs/oTLsNlTH6xvYb+iux7yly2hZGwhfBLzPGBsbeMZukZ96IphJTagT+C033s6LNVA==",
       "dev": true,
       "optional": true
     },
     "@next/swc-win32-arm64-msvc": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.0.1.tgz",
-      "integrity": "sha512-+ucLe2qgQzP+FM94jD4ns6LDGyMFaX9k3lVHqu/tsQCy2giMymbport4y4p77mYcXEMlDaHMzlHgOQyHRniWFA==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.0.3.tgz",
+      "integrity": "sha512-Q4BM16Djl+Oah9UdGrvjFYgoftYB2jNd+rtRGPX5Mmxo09Ry/KiLbOZnoUyoIxKc1xPyfqMXuaVsAFQLYs0KEQ==",
       "dev": true,
       "optional": true
     },
     "@next/swc-win32-ia32-msvc": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.0.1.tgz",
-      "integrity": "sha512-Krr/qGN7OB35oZuvMAZKoXDt2IapynIWLh5A5rz6AODb7f/ZJqyAuZSK12vOa2zKdobS36Qm4IlxxBqn9c00MA==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.0.3.tgz",
+      "integrity": "sha512-Sa8yGkNeRUsic8Qjf7MLIAfP0p0+einK/wIqJ8UO1y76j+8rRQu42AMs5H4Ax1fm9GEYq6I8njHtY59TVpTtGQ==",
       "dev": true,
       "optional": true
     },
     "@next/swc-win32-x64-msvc": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.0.1.tgz",
-      "integrity": "sha512-t/0G33t/6VGWZUGCOT7rG42qqvf/x+MrFp1CU+8CN6PrjSSL57R5bqkXfubV9t4eCEnUxVP+5Hn3MoEXEebtEw==",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.0.3.tgz",
+      "integrity": "sha512-IAptmSqA7k4tQzaw2NAkoEjj3+Dz9ceuvlEHwYh770MMDL4V0ku2m+UHrmn5HUCEDHhgwwjg2nyf6728q2jr1w==",
       "dev": true,
       "optional": true
     },
@@ -15676,6 +15863,20 @@
       "resolved": "https://registry.npmjs.org/@panva/hkdf/-/hkdf-1.0.2.tgz",
       "integrity": "sha512-MSAs9t3Go7GUkMhpKC44T58DJ5KGk2vBo+h1cqQeqlMfdGkxaVB78ZWpv9gYi/g2fa4sopag9gJsNvS8XGgWJA=="
     },
+    "@pkgr/utils": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.3.1.tgz",
+      "integrity": "sha512-wfzX8kc1PMyUILA+1Z/EqoE4UCXGy0iRGMhPwdfae1+f0OXlLqCk+By+aMzgJBzR9AzS4CDizioG6Ss1gvAFJw==",
+      "dev": true,
+      "requires": {
+        "cross-spawn": "^7.0.3",
+        "is-glob": "^4.0.3",
+        "open": "^8.4.0",
+        "picocolors": "^1.0.0",
+        "tiny-glob": "^0.2.9",
+        "tslib": "^2.4.0"
+      }
+    },
     "@sideway/address": {
       "version": "4.1.3",
       "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.3.tgz",
@@ -18077,6 +18278,12 @@
       "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg==",
       "dev": true
     },
+    "define-lazy-prop": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz",
+      "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==",
+      "dev": true
+    },
     "define-properties": {
       "version": "1.1.4",
       "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz",
@@ -18259,6 +18466,16 @@
         "once": "^1.4.0"
       }
     },
+    "enhanced-resolve": {
+      "version": "5.10.0",
+      "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz",
+      "integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==",
+      "dev": true,
+      "requires": {
+        "graceful-fs": "^4.2.4",
+        "tapable": "^2.2.0"
+      }
+    },
     "enquirer": {
       "version": "2.3.6",
       "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
@@ -18546,16 +18763,45 @@
       }
     },
     "eslint-import-resolver-typescript": {
-      "version": "2.7.1",
-      "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.7.1.tgz",
-      "integrity": "sha512-00UbgGwV8bSgUv34igBDbTOtKhqoRMy9bFjNehT40bXg6585PNIct8HhXZ0SybqB9rWtXj9crcku8ndDn/gIqQ==",
+      "version": "3.5.2",
+      "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.5.2.tgz",
+      "integrity": "sha512-zX4ebnnyXiykjhcBvKIf5TNvt8K7yX6bllTRZ14MiurKPjDpCAZujlszTdB8pcNXhZcOf+god4s9SjQa5GnytQ==",
       "dev": true,
       "requires": {
         "debug": "^4.3.4",
-        "glob": "^7.2.0",
+        "enhanced-resolve": "^5.10.0",
+        "get-tsconfig": "^4.2.0",
+        "globby": "^13.1.2",
+        "is-core-module": "^2.10.0",
         "is-glob": "^4.0.3",
-        "resolve": "^1.22.0",
-        "tsconfig-paths": "^3.14.1"
+        "synckit": "^0.8.4"
+      },
+      "dependencies": {
+        "globby": {
+          "version": "13.1.2",
+          "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz",
+          "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==",
+          "dev": true,
+          "requires": {
+            "dir-glob": "^3.0.1",
+            "fast-glob": "^3.2.11",
+            "ignore": "^5.2.0",
+            "merge2": "^1.4.1",
+            "slash": "^4.0.0"
+          }
+        },
+        "ignore": {
+          "version": "5.2.0",
+          "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
+          "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
+          "dev": true
+        },
+        "slash": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
+          "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==",
+          "dev": true
+        }
       }
     },
     "eslint-module-utils": {
@@ -19290,6 +19536,12 @@
         "get-intrinsic": "^1.1.1"
       }
     },
+    "get-tsconfig": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.2.0.tgz",
+      "integrity": "sha512-X8u8fREiYOE6S8hLbq99PeykTDoLVnxvF4DjWKJmz9xy2nNRdUcV8ZN9tniJFeKyTU3qnC9lL8n4Chd6LmVKHg==",
+      "dev": true
+    },
     "getmac": {
       "version": "5.20.0",
       "resolved": "https://registry.npmjs.org/getmac/-/getmac-5.20.0.tgz",
@@ -19366,6 +19618,12 @@
         "type-fest": "^0.20.2"
       }
     },
+    "globalyzer": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
+      "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==",
+      "dev": true
+    },
     "globby": {
       "version": "11.1.0",
       "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
@@ -19388,6 +19646,12 @@
         }
       }
     },
+    "globrex": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
+      "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==",
+      "dev": true
+    },
     "got": {
       "version": "11.8.5",
       "resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz",
@@ -19739,9 +20003,9 @@
       }
     },
     "is-core-module": {
-      "version": "2.9.0",
-      "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",
-      "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",
+      "version": "2.11.0",
+      "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",
+      "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
       "dev": true,
       "requires": {
         "has": "^1.0.3"
@@ -19753,6 +20017,12 @@
       "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==",
       "dev": true
     },
+    "is-docker": {
+      "version": "2.2.1",
+      "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
+      "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
+      "dev": true
+    },
     "is-extglob": {
       "version": "2.1.1",
       "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -19955,6 +20225,15 @@
         "get-intrinsic": "^1.1.1"
       }
     },
+    "is-wsl": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
+      "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
+      "dev": true,
+      "requires": {
+        "is-docker": "^2.0.0"
+      }
+    },
     "is-yarn-global": {
       "version": "0.3.0",
       "resolved": "https://registry.npmjs.org/is-yarn-global/-/is-yarn-global-0.3.0.tgz",
@@ -22438,25 +22717,25 @@
       "dev": true
     },
     "next": {
-      "version": "13.0.1",
-      "resolved": "https://registry.npmjs.org/next/-/next-13.0.1.tgz",
-      "integrity": "sha512-ErCNBPIeZMKFn6hX+ZBSlqZVgJIeitEqhGTuQUNmYXJ07/A71DZ7AJI8eyHYUdBb686LUpV1/oBdTq9RpzRVPg==",
-      "dev": true,
-      "requires": {
-        "@next/env": "13.0.1",
-        "@next/swc-android-arm-eabi": "13.0.1",
-        "@next/swc-android-arm64": "13.0.1",
-        "@next/swc-darwin-arm64": "13.0.1",
-        "@next/swc-darwin-x64": "13.0.1",
-        "@next/swc-freebsd-x64": "13.0.1",
-        "@next/swc-linux-arm-gnueabihf": "13.0.1",
-        "@next/swc-linux-arm64-gnu": "13.0.1",
-        "@next/swc-linux-arm64-musl": "13.0.1",
-        "@next/swc-linux-x64-gnu": "13.0.1",
-        "@next/swc-linux-x64-musl": "13.0.1",
-        "@next/swc-win32-arm64-msvc": "13.0.1",
-        "@next/swc-win32-ia32-msvc": "13.0.1",
-        "@next/swc-win32-x64-msvc": "13.0.1",
+      "version": "13.0.3",
+      "resolved": "https://registry.npmjs.org/next/-/next-13.0.3.tgz",
+      "integrity": "sha512-rFQeepcenRxKzeKlh1CsmEnxsJwhIERtbUjmYnKZyDInZsU06lvaGw5DT44rlNp1Rv2MT/e9vffZ8vK+ytwXHA==",
+      "dev": true,
+      "requires": {
+        "@next/env": "13.0.3",
+        "@next/swc-android-arm-eabi": "13.0.3",
+        "@next/swc-android-arm64": "13.0.3",
+        "@next/swc-darwin-arm64": "13.0.3",
+        "@next/swc-darwin-x64": "13.0.3",
+        "@next/swc-freebsd-x64": "13.0.3",
+        "@next/swc-linux-arm-gnueabihf": "13.0.3",
+        "@next/swc-linux-arm64-gnu": "13.0.3",
+        "@next/swc-linux-arm64-musl": "13.0.3",
+        "@next/swc-linux-x64-gnu": "13.0.3",
+        "@next/swc-linux-x64-musl": "13.0.3",
+        "@next/swc-win32-arm64-msvc": "13.0.3",
+        "@next/swc-win32-ia32-msvc": "13.0.3",
+        "@next/swc-win32-x64-msvc": "13.0.3",
         "@swc/helpers": "0.4.11",
         "caniuse-lite": "^1.0.30001406",
         "postcss": "8.4.14",
@@ -22722,6 +23001,17 @@
       "integrity": "sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=",
       "dev": true
     },
+    "open": {
+      "version": "8.4.0",
+      "resolved": "https://registry.npmjs.org/open/-/open-8.4.0.tgz",
+      "integrity": "sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==",
+      "dev": true,
+      "requires": {
+        "define-lazy-prop": "^2.0.0",
+        "is-docker": "^2.1.1",
+        "is-wsl": "^2.2.0"
+      }
+    },
     "openid-client": {
       "version": "5.2.1",
       "resolved": "https://registry.npmjs.org/openid-client/-/openid-client-5.2.1.tgz",
@@ -24126,6 +24416,16 @@
       "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
       "dev": true
     },
+    "synckit": {
+      "version": "0.8.4",
+      "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.4.tgz",
+      "integrity": "sha512-Dn2ZkzMdSX827QbowGbU/4yjWuvNaCoScLLoMo/yKbu+P4GBR6cRGKZH27k6a9bRzdqcyd1DE96pQtQ6uNkmyw==",
+      "dev": true,
+      "requires": {
+        "@pkgr/utils": "^2.3.1",
+        "tslib": "^2.4.0"
+      }
+    },
     "table": {
       "version": "6.8.0",
       "resolved": "https://registry.npmjs.org/table/-/table-6.8.0.tgz",
@@ -24170,6 +24470,12 @@
         }
       }
     },
+    "tapable": {
+      "version": "2.2.1",
+      "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
+      "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
+      "dev": true
+    },
     "tar-stream": {
       "version": "2.2.0",
       "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
@@ -24267,6 +24573,16 @@
       "integrity": "sha512-W3AmPTJWZkRwu+iSNxPIsLZ2ByADsOLbbLxe46UJyWj3mlYLlwucKiq+/dPm0l9wTzqoF3/2PH0AGFCebjq23A==",
       "dev": true
     },
+    "tiny-glob": {
+      "version": "0.2.9",
+      "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
+      "integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
+      "dev": true,
+      "requires": {
+        "globalyzer": "0.1.0",
+        "globrex": "^0.1.2"
+      }
+    },
     "tmp": {
       "version": "0.2.1",
       "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
diff --git a/package.json b/package.json
index 68bdcf3c..622038ee 100644
--- a/package.json
+++ b/package.json
@@ -2,17 +2,25 @@
   "name": "@auth0/nextjs-auth0",
   "version": "2.0.0-beta.3",
   "description": "Next.js SDK for signing in with Auth0",
+  "exports": {
+    ".": "./dist/index.js",
+    "./client": "./dist/client/index.js",
+    "./edge": "./dist/edge.js",
+    "./testing": "./dist/helpers/testing.js"
+  },
   "main": "dist/index.js",
   "types": "dist/index.d.ts",
-  "browser": "dist/index.browser.js",
+  "browser": "dist/client/index.js",
   "directories": {
     "test": "tests"
   },
   "files": [
     "dist",
     "src",
-    "middleware.js",
-    "middleware.d.ts",
+    "client.js",
+    "client.d.ts",
+    "edge.js",
+    "edge.d.ts",
     "testing.js",
     "testing.d.ts"
   ],
@@ -88,14 +96,14 @@
     "cypress": "^8.4.0",
     "eslint": "^7.17.0",
     "eslint-config-prettier": "^8.1.0",
-    "eslint-import-resolver-typescript": "^2.3.0",
+    "eslint-import-resolver-typescript": "^3.5.2",
     "eslint-plugin-import": "^2.22.1",
     "eslint-plugin-jsx-a11y": "^6.4.1",
     "eslint-plugin-prettier": "^3.3.1",
     "eslint-plugin-react": "^7.22.0",
     "eslint-plugin-react-hooks": "^4.2.0",
     "jest": "^27.2.0",
-    "next": "^13.0.1",
+    "next": "^13.0.3",
     "nock": "^13.0.5",
     "oidc-provider": "^7.6.0",
     "on-headers": "^1.0.2",
@@ -135,9 +143,7 @@
     ],
     "collectCoverageFrom": [
       "<rootDir>/src/**/*.*",
-      "!<rootDir>/src/index.browser.ts",
-      "!<rootDir>/src/middleware.ts",
-      "!<rootDir>/src/instance.ts",
+      "!<rootDir>/src/edge.ts",
       "!<rootDir>/src/auth0-session/config.ts",
       "!<rootDir>/src/auth0-session/index.ts",
       "!<rootDir>/src/auth0-session/session-cache.ts"
diff --git a/src/frontend/index.ts b/src/client/index.ts
similarity index 54%
rename from src/frontend/index.ts
rename to src/client/index.ts
index 28f5532b..23960346 100644
--- a/src/frontend/index.ts
+++ b/src/client/index.ts
@@ -1,5 +1,5 @@
-export { default as ConfigProvider, ConfigProviderProps, useConfig } from './use-config';
-export {
+'use client';
+import {
   default as UserProvider,
   UserProviderProps,
   UserProfile,
@@ -7,9 +7,11 @@ export {
   RequestError,
   useUser
 } from './use-user';
-export {
+import {
   default as withPageAuthRequired,
   WithPageAuthRequired,
   WithPageAuthRequiredProps,
   WithPageAuthRequiredOptions
 } from './with-page-auth-required';
+export { UserProvider, UserProviderProps, UserProfile, UserContext, RequestError, useUser };
+export { withPageAuthRequired, WithPageAuthRequired, WithPageAuthRequiredProps, WithPageAuthRequiredOptions };
diff --git a/src/frontend/use-config.tsx b/src/client/use-config.tsx
similarity index 97%
rename from src/frontend/use-config.tsx
rename to src/client/use-config.tsx
index b4e0a027..d99c1537 100644
--- a/src/frontend/use-config.tsx
+++ b/src/client/use-config.tsx
@@ -1,3 +1,4 @@
+'use client';
 import React, { ReactElement, useContext, createContext } from 'react';
 
 export type ConfigContext = {
diff --git a/src/frontend/use-user.tsx b/src/client/use-user.tsx
similarity index 97%
rename from src/frontend/use-user.tsx
rename to src/client/use-user.tsx
index a55cb2e3..f76f3c97 100644
--- a/src/frontend/use-user.tsx
+++ b/src/client/use-user.tsx
@@ -1,3 +1,4 @@
+'use client';
 import React, { ReactElement, useState, useEffect, useCallback, useContext, createContext } from 'react';
 
 import ConfigProvider, { ConfigContext } from './use-config';
@@ -75,7 +76,7 @@ type UserFetcher = (url: string) => Promise<UserProfile | undefined>;
  * ```js
  * // pages/_app.js
  * import React from 'react';
- * import { UserProvider } from '@auth0/nextjs-auth0';
+ * import { UserProvider } from '@auth0/nextjs-auth0/client';
  *
  * export default function App({ Component, pageProps }) {
  *   // If you've used `withPageAuthRequired`, `pageProps.user` can prefill the hook
@@ -139,7 +140,7 @@ export type UseUser = () => UserContext;
  * ```js
  * // pages/profile.js
  * import Link from 'next/link';
- * import { useUser } from '@auth0/nextjs-auth0';
+ * import { useUser } from '@auth0/nextjs-auth0/client';
  *
  * export default function Profile() {
  *   const { user, error, isLoading } = useUser();
diff --git a/src/frontend/with-page-auth-required.tsx b/src/client/with-page-auth-required.tsx
similarity index 99%
rename from src/frontend/with-page-auth-required.tsx
rename to src/client/with-page-auth-required.tsx
index 7883a8e4..9b86015a 100644
--- a/src/frontend/with-page-auth-required.tsx
+++ b/src/client/with-page-auth-required.tsx
@@ -1,3 +1,4 @@
+'use client';
 import React, { ComponentType, useEffect } from 'react';
 
 import { useConfig } from './use-config';
diff --git a/src/middleware.ts b/src/edge.ts
similarity index 87%
rename from src/middleware.ts
rename to src/edge.ts
index 3a80e634..1faf646b 100644
--- a/src/middleware.ts
+++ b/src/edge.ts
@@ -10,17 +10,17 @@ import {
 import { getConfig, ConfigParameters } from './config';
 import { setIsUsingNamedExports, setIsUsingOwnInstance } from './utils/instance-check';
 
-export type Instance = { withMiddlewareAuthRequired: WithMiddlewareAuthRequired; getSession: GetSession };
+export type Auth0Edge = { withMiddlewareAuthRequired: WithMiddlewareAuthRequired; getSession: GetSession };
 
 export type GetSession = (req: NextRequest, res: NextResponse) => Promise<Session | null | undefined>;
 
-export type InitAuth0 = (params?: ConfigParameters) => Instance;
+export type InitAuth0 = (params?: ConfigParameters) => Auth0Edge;
 
 export { WithMiddlewareAuthRequired };
 
-let instance: Instance;
+let instance: Auth0Edge;
 
-function getInstance(params?: ConfigParameters): Instance {
+function getInstance(params?: ConfigParameters): Auth0Edge {
   setIsUsingNamedExports();
   if (instance) {
     return instance;
diff --git a/src/helpers/with-page-auth-required.ts b/src/helpers/with-page-auth-required.ts
index ac588f0d..5cef9bf3 100644
--- a/src/helpers/with-page-auth-required.ts
+++ b/src/helpers/with-page-auth-required.ts
@@ -1,13 +1,6 @@
 import { GetServerSideProps, GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
 import { Claims, SessionCache } from '../session';
 import { assertCtx } from '../utils/assert';
-import React, { ComponentType } from 'react';
-import {
-  UserProps,
-  WithPageAuthRequiredOptions as WithPageAuthRequiredCSROptions,
-  WithPageAuthRequiredProps
-} from '../frontend/with-page-auth-required';
-import { withPageAuthRequired as withPageAuthRequiredCSR } from '../frontend';
 import { ParsedUrlQuery } from 'querystring';
 
 /**
@@ -90,13 +83,9 @@ export type WithPageAuthRequiredOptions<P = any, Q extends ParsedUrlQuery = Pars
  *
  * @category Server
  */
-export type WithPageAuthRequired = {
-  <P extends WithPageAuthRequiredProps>(
-    Component: ComponentType<P & UserProps>,
-    options?: WithPageAuthRequiredCSROptions
-  ): React.FC<P>;
-  <P, Q extends ParsedUrlQuery = ParsedUrlQuery>(opts?: WithPageAuthRequiredOptions<P, Q>): PageRoute<P, Q>;
-};
+export type WithPageAuthRequired = <P, Q extends ParsedUrlQuery = ParsedUrlQuery>(
+  opts?: WithPageAuthRequiredOptions<P, Q>
+) => PageRoute<P, Q>;
 
 /**
  * @ignore
@@ -105,15 +94,8 @@ export default function withPageAuthRequiredFactory(
   loginUrl: string,
   getSessionCache: () => SessionCache
 ): WithPageAuthRequired {
-  return (
-    optsOrComponent: WithPageAuthRequiredOptions | ComponentType<WithPageAuthRequiredProps & UserProps> = {},
-    csrOpts?: WithPageAuthRequiredCSROptions
-  ): any => {
-    if (typeof optsOrComponent === 'function') {
-      return withPageAuthRequiredCSR(optsOrComponent, csrOpts);
-    }
-    const { getServerSideProps, returnTo } = optsOrComponent;
-    return async (ctx: GetServerSidePropsContext): Promise<GetServerSidePropsResultWithSession> => {
+  return ({ getServerSideProps, returnTo } = {}) =>
+    async (ctx) => {
       assertCtx(ctx);
       const sessionCache = getSessionCache();
       const session = await sessionCache.get(ctx.req, ctx.res);
@@ -134,5 +116,4 @@ export default function withPageAuthRequiredFactory(
       }
       return { ...ret, props: { user: session.user, ...ret.props } };
     };
-  };
 }
diff --git a/src/index.browser.ts b/src/index.browser.ts
deleted file mode 100644
index d550208a..00000000
--- a/src/index.browser.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import { InitAuth0, SignInWithAuth0 } from './instance';
-import { GetAccessToken, GetSession } from './session';
-import { WithApiAuthRequired } from './helpers';
-import { HandleAuth, HandleCallback, HandleLogin, HandleLogout, HandleProfile } from './handlers';
-export {
-  UserProvider,
-  UserProviderProps,
-  UserProfile,
-  UserContext,
-  RequestError,
-  useUser,
-  withPageAuthRequired,
-  WithPageAuthRequired
-} from './frontend';
-
-const serverSideOnly = (method: string): string => `The ${method} method can only be used from the server side`;
-
-const instance: SignInWithAuth0 = {
-  getSession() {
-    throw new Error(serverSideOnly('getSession'));
-  },
-  updateSession() {
-    throw new Error(serverSideOnly('updateSession'));
-  },
-  getAccessToken() {
-    throw new Error(serverSideOnly('getAccessToken'));
-  },
-  withApiAuthRequired() {
-    throw new Error(serverSideOnly('withApiAuthRequired'));
-  },
-  handleLogin() {
-    throw new Error(serverSideOnly('handleLogin'));
-  },
-  handleLogout() {
-    throw new Error(serverSideOnly('handleLogout'));
-  },
-  handleCallback() {
-    throw new Error(serverSideOnly('handleCallback'));
-  },
-  handleProfile() {
-    throw new Error(serverSideOnly('handleProfile'));
-  },
-  handleAuth() {
-    throw new Error(serverSideOnly('handleAuth'));
-  },
-  withPageAuthRequired() {
-    throw new Error(serverSideOnly('withPageAuthRequired'));
-  }
-};
-
-export const initAuth0: InitAuth0 = () => instance;
-export const getSession: GetSession = (...args) => instance.getSession(...args);
-export const getAccessToken: GetAccessToken = (...args) => instance.getAccessToken(...args);
-export const withApiAuthRequired: WithApiAuthRequired = (...args) => instance.withApiAuthRequired(...args);
-export const handleLogin: HandleLogin = ((...args: Parameters<HandleLogin>) =>
-  instance.handleLogin(...args)) as HandleLogin;
-export const handleLogout: HandleLogout = ((...args: Parameters<HandleLogout>) =>
-  instance.handleLogout(...args)) as HandleLogout;
-export const handleCallback: HandleCallback = ((...args: Parameters<HandleCallback>) =>
-  instance.handleCallback(...args)) as HandleCallback;
-export const handleProfile: HandleProfile = ((...args: Parameters<HandleProfile>) =>
-  instance.handleProfile(...args)) as HandleProfile;
-export const handleAuth: HandleAuth = (...args) => instance.handleAuth(...args);
diff --git a/src/index.ts b/src/index.ts
index 079d5156..9909d543 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -50,15 +50,84 @@ import {
   WithPageAuthRequiredOptions,
   PageRoute
 } from './helpers';
-import { InitAuth0, SignInWithAuth0 } from './instance';
 import version from './version';
 import { getConfig, getLoginUrl, ConfigParameters } from './config';
 import { setIsUsingNamedExports, setIsUsingOwnInstance } from './utils/instance-check';
 
-let instance: SignInWithAuth0 & { sessionCache: SessionCache };
+/**
+ * The SDK server instance.
+ *
+ * This is created for you when you use the named exports, or you can create your own using {@link InitAuth0}.
+ *
+ * See {@link ConfigParameters} for more info.
+ *
+ * @category Server
+ */
+export interface Auth0Server {
+  /**
+   * Session getter.
+   */
+  getSession: GetSession;
+
+  /**
+   * Append properties to the user.
+   */
+  updateSession: UpdateSession;
+
+  /**
+   * Access token getter.
+   */
+  getAccessToken: GetAccessToken;
+
+  /**
+   * Login handler which will redirect the user to Auth0.
+   */
+  handleLogin: HandleLogin;
+
+  /**
+   * Callback handler which will complete the transaction and create a local session.
+   */
+  handleCallback: HandleCallback;
+
+  /**
+   * Logout handler which will clear the local session and the Auth0 session.
+   */
+  handleLogout: HandleLogout;
+
+  /**
+   * Profile handler which return profile information about the user.
+   */
+  handleProfile: HandleProfile;
+
+  /**
+   * Helper that adds auth to an API route.
+   */
+  withApiAuthRequired: WithApiAuthRequired;
+
+  /**
+   * Helper that adds auth to a Page route.
+   */
+  withPageAuthRequired: WithPageAuthRequired;
+
+  /**
+   * Create the main handlers for your api routes.
+   */
+  handleAuth: HandleAuth;
+}
+
+/**
+ * Initialise your own instance of the SDK.
+ *
+ * See {@link ConfigParameters}.
+ *
+ * @category Server
+ */
+export type InitAuth0 = (params?: ConfigParameters) => Auth0Server;
+
+let instance: Auth0Server & { sessionCache: SessionCache };
 
 // For using managed instance with named exports.
-function getInstance(): SignInWithAuth0 & { sessionCache: SessionCache } {
+function getInstance(): Auth0Server & { sessionCache: SessionCache } {
   setIsUsingNamedExports();
   if (instance) {
     return instance;
@@ -74,7 +143,7 @@ export const initAuth0: InitAuth0 = (params) => {
   return publicApi;
 };
 
-export const _initAuth = (params?: ConfigParameters): SignInWithAuth0 & { sessionCache: SessionCache } => {
+export const _initAuth = (params?: ConfigParameters): Auth0Server & { sessionCache: SessionCache } => {
   const { baseConfig, nextConfig } = getConfig(params);
 
   // Init base layer (with base config)
@@ -130,16 +199,6 @@ export const handleProfile: HandleProfile = ((...args: Parameters<HandleProfile>
   getInstance().handleProfile(...args)) as HandleProfile;
 export const handleAuth: HandleAuth = (...args) => getInstance().handleAuth(...args);
 
-export {
-  UserProvider,
-  UserProviderProps,
-  UserProfile,
-  UserContext,
-  RequestError,
-  useUser,
-  WithPageAuthRequiredProps
-} from './frontend';
-
 export {
   AuthError,
   AccessTokenErrorCode,
@@ -186,7 +245,6 @@ export {
   LoginOptions,
   LogoutOptions,
   GetLoginState,
-  InitAuth0,
   OnError
 };
 /* c8 ignore stop */
diff --git a/src/instance.ts b/src/instance.ts
deleted file mode 100644
index 5c3892ca..00000000
--- a/src/instance.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { GetSession, GetAccessToken, UpdateSession } from './session';
-import { WithApiAuthRequired, WithPageAuthRequired } from './helpers';
-import { HandleAuth, HandleCallback, HandleLogin, HandleLogout, HandleProfile } from './handlers';
-import { ConfigParameters } from './auth0-session';
-
-/**
- * The SDK server instance.
- *
- * This is created for you when you use the named exports, or you can create your own using {@link InitAuth0}.
- *
- * See {@link ConfigParameters} for more info.
- *
- * @category Server
- */
-export interface SignInWithAuth0 {
-  /**
-   * Session getter.
-   */
-  getSession: GetSession;
-
-  /**
-   * Append properties to the user.
-   */
-  updateSession: UpdateSession;
-
-  /**
-   * Access token getter.
-   */
-  getAccessToken: GetAccessToken;
-
-  /**
-   * Login handler which will redirect the user to Auth0.
-   */
-  handleLogin: HandleLogin;
-
-  /**
-   * Callback handler which will complete the transaction and create a local session.
-   */
-  handleCallback: HandleCallback;
-
-  /**
-   * Logout handler which will clear the local session and the Auth0 session.
-   */
-  handleLogout: HandleLogout;
-
-  /**
-   * Profile handler which return profile information about the user.
-   */
-  handleProfile: HandleProfile;
-
-  /**
-   * Helper that adds auth to an API route.
-   */
-  withApiAuthRequired: WithApiAuthRequired;
-
-  /**
-   * Helper that adds auth to a Page route.
-   */
-  withPageAuthRequired: WithPageAuthRequired;
-
-  /**
-   * Create the main handlers for your api routes.
-   */
-  handleAuth: HandleAuth;
-}
-
-/**
- * Initialise your own instance of the SDK.
- *
- * See {@link ConfigParameters}.
- *
- * @category Server
- */
-export type InitAuth0 = (params?: ConfigParameters) => SignInWithAuth0;
diff --git a/typedoc.js b/typedoc.js
index b1fae47f..64cf6d0e 100644
--- a/typedoc.js
+++ b/typedoc.js
@@ -4,10 +4,8 @@ module.exports = {
   exclude: [
     './src/auth0-session/**',
     './src/session/cache.ts',
-    './src/frontend/use-config.tsx',
-    './src/utils/!(errors.ts)',
-    './src/index.ts',
-    './src/index.browser.ts'
+    './src/client/use-config.tsx',
+    './src/utils/!(errors.ts)'
   ],
   excludeExternals: true,
   excludePrivate: true,


Test patch:
diff --git a/src/helpers/testing.ts b/src/helpers/testing.ts
index 7c85b9a4..05ce5bf5 100644
--- a/src/helpers/testing.ts
+++ b/src/helpers/testing.ts
@@ -1,6 +1,24 @@
-import { Config as BaseConfig, CookieStore, NodeCookies as Cookies } from '../auth0-session';
+import { Config as BaseConfig, CookieConfig, CookieStore, NodeCookies as Cookies } from '../auth0-session';
 import { Session } from '../session';
-import { GenerateSessionCookieConfig } from '../../testing';
+
+/**
+ * Configuration parameters used by {@link generateSessionCookie}.
+ */
+export type GenerateSessionCookieConfig = {
+  /**
+   * The secret used to derive an encryption key for the session cookie.
+   *
+   * **IMPORTANT**: you must use the same value as in the SDK configuration.
+   * See {@link ConfigParameters.secret}.
+   */
+  secret: string;
+
+  /**
+   * Integer value, in seconds, used as the duration of the session cookie.
+   * Defaults to `604800` seconds (7 days).
+   */
+  duration?: number;
+} & Partial<CookieConfig>;
 
 export const generateSessionCookie = async (
   session: Partial<Session>,
diff --git a/testing.d.ts b/testing.d.ts
index e8fdc3dd..8de841c2 100644
--- a/testing.d.ts
+++ b/testing.d.ts
@@ -1,39 +1,1 @@
-import type { CookieConfig } from './dist/config';
-import type { Session } from './dist/session';
-
-/**
- * Configuration parameters used by ({@link generateSessionCookie}.
- */
-export type GenerateSessionCookieConfig = {
-  /**
-   * The secret used to derive an encryption key for the session cookie.
-   *
-   * **IMPORTANT**: you must use the same value as in the SDK configuration.
-   * See {@link ConfigParameters.secret}.
-   */
-  secret: string;
-
-  /**
-   * Integer value, in seconds, used as the duration of the session cookie.
-   * Defaults to `604800` seconds (7 days).
-   */
-  duration?: number;
-} & Partial<CookieConfig>;
-
-/**
- * Generates an encrypted session cookie that can be used to mock the Auth0
- * authentication flow in e2e tests.
- *
- * **IMPORTANT**: this utility can only run on Node.js, **not on the browser**.
- * For example, if you're using [Cypress](https://www.cypress.io/), you can
- * wrap it in a [task](https://docs.cypress.io/api/commands/task) and then
- * invoke the task from a test or a custom command.
- *
- * @param {Session} session The user's session.
- * @param {GenerateSessionCookieConfig} config Configuration parameters for the session cookie.
- * @return {String}
- */
-export declare function generateSessionCookie(
-  session: Partial<Session>,
-  config: GenerateSessionCookieConfig
-): Promise<string>;
+export type * from './dist/helpers/testing';
diff --git a/tests/fixtures/frontend.tsx b/tests/fixtures/frontend.tsx
index 4c9a96b4..5d105fa5 100644
--- a/tests/fixtures/frontend.tsx
+++ b/tests/fixtures/frontend.tsx
@@ -1,13 +1,7 @@
 import React from 'react';
 
-import {
-  ConfigProvider,
-  ConfigProviderProps,
-  RequestError,
-  UserProvider,
-  UserProviderProps,
-  UserProfile
-} from '../../src/frontend';
+import { RequestError, UserProvider, UserProviderProps, UserProfile } from '../../src/client';
+import { default as ConfigProvider, ConfigProviderProps } from '../../src/client/use-config';
 
 type FetchUserMock = {
   ok: boolean;
diff --git a/tests/frontend/use-config.test.ts b/tests/frontend/use-config.test.ts
index a17210ec..d79c1a69 100644
--- a/tests/frontend/use-config.test.ts
+++ b/tests/frontend/use-config.test.ts
@@ -1,7 +1,7 @@
 import { renderHook } from '@testing-library/react-hooks';
 
 import { withConfigProvider } from '../fixtures/frontend';
-import { useConfig } from '../../src/frontend/use-config';
+import { useConfig } from '../../src/client/use-config';
 
 describe('context wrapper', () => {
   test('should provide the default login url', async () => {
diff --git a/tests/frontend/use-user.test.tsx b/tests/frontend/use-user.test.tsx
index 443bd0b8..26da42c0 100644
--- a/tests/frontend/use-user.test.tsx
+++ b/tests/frontend/use-user.test.tsx
@@ -8,8 +8,8 @@ import {
   withUserProvider,
   user
 } from '../fixtures/frontend';
-import { RequestError, useConfig } from '../../src/frontend';
-import { useUser, UserContext } from '../../src';
+import { useUser, UserContext, RequestError } from '../../src/client';
+import { useConfig } from '../../src/client/use-config';
 import React from 'react';
 
 describe('context wrapper', () => {
diff --git a/tests/frontend/with-page-auth-required.test.tsx b/tests/frontend/with-page-auth-required.test.tsx
index 0a6e045d..eda022aa 100644
--- a/tests/frontend/with-page-auth-required.test.tsx
+++ b/tests/frontend/with-page-auth-required.test.tsx
@@ -6,7 +6,7 @@ import React from 'react';
 import { render, screen, waitFor } from '@testing-library/react';
 
 import { fetchUserErrorMock, withUserProvider, user } from '../fixtures/frontend';
-import { withPageAuthRequired } from '../../src/frontend';
+import { withPageAuthRequired } from '../../src/client';
 
 const windowLocation = window.location;
 
diff --git a/tests/helpers/with-middleware-auth-required.test.ts b/tests/helpers/with-middleware-auth-required.test.ts
index b9f6672e..51e801ab 100644
--- a/tests/helpers/with-middleware-auth-required.test.ts
+++ b/tests/helpers/with-middleware-auth-required.test.ts
@@ -3,7 +3,7 @@
  */
 import { NextRequest, NextResponse } from 'next/server';
 import { NextFetchEvent } from 'next/dist/server/web/spec-extension/fetch-event';
-import { initAuth0 } from '../../src/middleware';
+import { initAuth0 } from '../../src/edge';
 import { withoutApi } from '../fixtures/default-settings';
 import { IdTokenClaims } from 'openid-client';
 import { encryption as deriveKey } from '../../src/auth0-session/utils/hkdf';
diff --git a/tests/index.test.ts b/tests/index.test.ts
index 9d2adfcb..87cfcc67 100644
--- a/tests/index.test.ts
+++ b/tests/index.test.ts
@@ -57,7 +57,7 @@ describe('index', () => {
     );
   });
 
-  test('should share insance when using named exports', async () => {
+  test('should share instance when using named exports', async () => {
     updateEnv(withoutApi);
     const req = new IncomingMessage(new Socket());
     const res = new ServerResponse(req);