NextJS Auth Example
The example is a NextJS app with authentication using NextAuth.js.
It uses MongoDB to persist user accounts and support email sign in. Adding additional providers is as simple as commenting them out from
💁♀️ How to use
- Click the
Deploy on Railway button above
- Add the required environment variables (
EMAIL_SERVER has to be a connection string in this format -
- Clone the project locally
- Install dependencies -
- Connect to your Railway project -
- Start the development server
railway run yarn dev
- The value for
NEXTAUTH_URL is set to
http://localhost:3000 for ease of use. You must update it before deploying to production.
- You can read more about how the email provider works here.
- You can read more about how objects are stored in the database here.
- If you want to configure additional providers, you can do so using the information mentioned here.