This template provides a quick start for building web applications with Next.js, featuring Google Authentication out of the box. It's designed to be a solid foundation for your side projects, allowing you to focus on building features rather than setting up the basics.
- Frontend Framework: Next.js (using the App Router)
- Styling: Shadcn
- Database: SQLite with Prisma as ORM
- Authentication: NextAuth.js
- ORM: Prisma
- Language: TypeScript
- Pre-configured Google Authentication
- Modern, responsive UI with Shadcn components
- Type-safe database operations with Prisma
- Built with TypeScript for enhanced developer experience
-
Clone this repository:
git clone https://github.com/yourusername/nextjs-google-auth-template.git cd nextjs-google-auth-template -
Install dependencies:
npm install -
Set up your environment variables:
- Copy
.env.exampleto.env.local - Fill in your Google OAuth credentials and other necessary variables
- Copy
-
Set up the database:
npx prisma migrate dev -
Run the development server:
npm run dev -
Open http://localhost:3000 in your browser to see the result.
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Navigate to "APIs & Services" > "Credentials"
- Click "Create Credentials" and select "OAuth client ID"
- Choose "Web application" as the application type
- Add
http://localhost:3000to the Authorized JavaScript origins - Add
http://localhost:3000/api/auth/callback/googleto the Authorized redirect URIs - Copy the Client ID and Client Secret
- Paste these values into your
.env.localfile:GOOGLE_CLIENT_ID=your_client_id_here GOOGLE_CLIENT_SECRET=your_client_secret_here
- Modify the Prisma schema in
prisma/schema.prismato fit your data model - Adjust the authentication options in
pages/api/auth/[...nextauth].ts - Customize the UI components in the
componentsdirectory
This template is ready for deployment on platforms like Vercel or Netlify. Make sure to set up your environment variables in your deployment platform's settings.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.