This is a template for a Next Js application with Clerk authentication and MongoDB and Typescript. Along with it, it includes Shadcn usage as well (no need to bunx shadcn init anymore LOL)
- Clerk Auth
- MongoDB
- Middeware
- Error handling
- Typesafe
- Clone the repository
git clone https://github.com/subhadeeproy3902/next-clerk-mongo-template.git
or download the zip file. - Open the project in your favorite code editor.
- Navigate to the project directory
cd next-clerk-mongo-template
. - Create a
.env
file in the frontend directory and add the following environment variables:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY= <Your Clerk Publishable Key>
CLERK_SECRET_KEY= <Your Clerk Secret Key>
MONGO_URI= <Your MongoDB connection string>
WEBHOOK_SECRET= <Your Webhook secret>
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
NOTE : Create then get the Webhook secret from Clerk Dashboad. For more information. Read Clerk Webhook Docs
Also do select user
in the filter box
- Start the development server
npm run dev
oryarn dev
orpnpm dev
orbun dev
. - Open http://localhost:3000 in your browser.
-
The user can sign up with email and password or with Google or with any other auth providers as per your clerk setup. The Credentials are stored in Clerk and the user data is stored in MongoDB.
-
The user will be redirected to the respective dashboard page.
-
The user can sign out from the dashboard page and will be redirected to the home page (
/
).
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
If you like the project, give a star ⭐ to the repository and share it with others. Also you can use this as a template too for your works as well