A robust authentication template built with Next.js, featuring React Server Components, NextAuth, PostgreSQL database integration, and Tailwind CSS for styling.
- Next.js App Router
- React Server Components
- NextAuth for authentication
- PostgreSQL database integration with Prisma ORM
- Tailwind CSS for responsive design
- TypeScript support
- User registration and sign-in functionality
-
Clone the repository:
git clone https://github.com/yourusername/nextjs-auth-template.git cd nextjs-auth-template
-
Install dependencies:
npm install
-
Set up your environment variables:
- Copy
.env.example
to.env.local
- Update the variables with your database and NextAuth configuration
- Set up the database:
npx prisma generate npx prisma db push
I have setup some sample schema in the prisma folder and you're welcome to use this as an example or just remove it entirely
- Run the development server:
npm run dev
- Open http://localhost:3000 in your browser to see the result.
- The project uses Railway for PostgreSQL hosting. Make sure to update the DATABASE_URL in your .env file with the correct credentials.
- bcryptjs is used for password hashing. Ensure you have @types/bcryptjs installed for TypeScript support.
- The main page layout is componentized with a separate Nav component for better organisation.
- Styled modules are used for component-specific styling, allowing for better CSS isolation.
Built with test deployment on Railway but you can use Netlify or Vercel if you wish - I used Railway's DB config tool and it worked out of the box.