In Waitlist mode, users can register their interest in your app by joining a waitlist. This mode is ideal for apps in early development stages or those wanting to generate interest before launch. This guide shows you how to get Clerk integrated and how to add a waitlist to your Next.js application.
The <Waitlist /> component renders a form that allows users to join for early access to your app.
The following example includes a basic implementation of the <Waitlist /> component hosted on the / route (the home page). You can use this as a starting point for your own implementation.
The <ClerkProvider> component provides session and user context to Clerk's hooks and components. It's recommended to wrap your entire app at the entry point with <ClerkProvider> to make authentication globally accessible. See the reference docs for other configuration options.
To use the <Waitlist /> component in your app, you must provide the waitlistUrl prop, which points to the URL of your waitlist page.
clerkMiddleware()Next.js Icon grants you access to user authentication state throughout your app, on any route or page. It also allows you to protect specific routes from unauthenticated users. To add clerkMiddleware() to your app, follow these steps:
Create a middleware.ts file.
If you're using the /src directory, create middleware.ts in the /src directory.
If you're not using the /src directory, create middleware.ts in the root directory alongside .env.
In your middleware.ts file, export the clerkMiddleware() helper:
middleware.ts
import { clerkMiddleware } from'@clerk/nextjs/server'exportdefaultclerkMiddleware()exportconstconfig= { matcher: [// Skip Next.js internals and all static files, unless found in search params'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',// Always run for API routes'/(api|trpc)(.*)', ],}
By default, clerkMiddleware() will not protect any routes. All routes are public and you must opt-in to protection for routes. See the clerkMiddleware() referenceNext.js Icon to learn how to require authentication for specific routes.
Update your environment variables to point to your custom sign-in page. For more information on building a custom sign-in-or-up page, see the dedicated guideNext.js Icon.