Skip to content
/ nextjs-starter Public template

A starter project for next js with authentication - Contains React 17 + Typescript + Tailwind CSS 2 + React Query 3 + GitHub Auth + LinkedIn Auth + Password-less Auth + Fauna DB + ESLint + Prettier + Husky

License

Notifications You must be signed in to change notification settings

pbteja1998/nextjs-starter

Repository files navigation

nextjs-starter

A Next.js starter kit template with React 17 + Typescript + Tailwind CSS 2 + React Query 3 + NextAuth.js (with GitHub Auth + Passwordless Auth) + Fauna DB

MIT License

styled with prettier

Demo

Run Locally

  • Clone the project

      git clone https://github.com/pbteja1998/nextjs-starter.git
  • Go to the project directory

      cd nextjs-starter
  • Install dependencies

      yarn
  • Create .env.local and change env variables as per the instructions.

      cp .env.example .env.local
  • Setup the database by running the following command and pasting the Fauna Secret key when prompted. More details at fauna-schema-migrate.

      yarn setup-db
  • Start the server

      yarn dev

Environment Variables

To run this project, you will need to add the following environment variables to your .env.local file

  • NEXTAUTH_URL
    • This is the your application URL. Locally, you can set this to http://localhost:3000
  • SECRET
    • Set this to any randomly generated string
  • EMAIL_SERVER
    • This is the email server string. It's in the format of smtp://username:password@smtp.example.com:587. Replace username, password and smtp.example.com with your own credentials.
  • EMAIL_FROM
    • Your email address from which you are sending emails.
  • GITHUB_ID
  • GITHUB_SECRET
    • You need to create a GitHub OAuth App, and get the GITHUB_ID AND GITHUB_SECRET from that app.
    • You can follow these instructions.
    • When creating an oauth app for local development, you can set the Homepage URL to http://localhost:3000 and Authorization Callback URL to http://localhost:3000/api/auth/callback/github
  • LINKEDIN_ID
  • LINKEDIN_SECRET
    • You need to create an oauth app for LINKEDIN. You can set the callback URL to http://localhost:3000/api/auth/callback/linkedin
  • FAUNADB_SECRET
    • Create a new fauna server key and set this variable to that key

FAQ

How to run Fauna locally?

Please note that this is completely optional. You can directly create your database in Fauna cloud and directly use the secret you generate there.

We are using Fauna Dev docker container to run Fauna instance locally.

These are the instructions to setup Fauna container locally.

# Pull the latest Docker container:
docker pull fauna/faunadb:latest

# Verify that the container executes correctly:
docker run fauna/faunadb --help

After you installed this, you can start the container using the following command

docker run --rm --name faunadb -p 8443:8443 -p 8084:8084 fauna/faunadb

Please note that this will create a new instance of Fauna everytime you run it, and all the data will be cleared when you stop this container. For other config options and approaches, go through the documentation.

Changes you need to do in the template:

  • You have to set USE_FAUNA_DOCKER=true in your .env.local file
  • Everytime you start the docker container, you need to first apply the migrations. You can do it by running yarn setup-docker-db.
  • More details at fauna-schema-migrate and Fauna Dev.

Feedback & Support

For feedback and support, please open an issue in this repo.

License

MIT

Roadmap

TBD

Contributing

TBD

Deploying

Vercel

TBD

Netlify

TBD