Next.js Starter Template With Authentication + React 17 + TypeScript + Tailwind CSS 2 + ESLint

Full-Stack Developer, Entrepreneur and Co-Founder of Coderplex.
Building https://coderplex.in
Checkout my portfolio at https://bhanuteja.dev
Search for a command to run...

Full-Stack Developer, Entrepreneur and Co-Founder of Coderplex.
Building https://coderplex.in
Checkout my portfolio at https://bhanuteja.dev
Your app isn't working. I tried to log in with an email and Github authentications but both failed.
Hi Tony Brown
I just tried to login both through email and Github. They both seem to work.
Are you using the correct website? This is the demo URL - https://next-starter.bhanuteja.dev/
If you have been using config similar to the with-tailwindcss example repo, then PostCSS config is the same.
In tailwind config, you have an extra darkMode: false option.
You also need to add postcss 8 as a dependency.
Authored in connection with the Write With Fauna program. Table of Contents Authentication Setting up Fauna in Next.js Installing Fauna Setting up Migrations Tool Authentication and Authorization in Fauna Next.js Serverless Function Setup for Fa...

I wanted to start blogging in Aug of 2020. I decided to use @hashnode for my blog. It was the best decision that I made. I wrote 27 technical articles so far. Most of them are about frontend web development. A thread 🧵 about each of these articles i...

In this article, I will list out all the git commands that I use very frequently. This is not in any way a complete list, just the commands that I use very often. This is intended to be used as a quick reference to perform an action that you want. ...

In this article, we will see the order in which different useEffect callbacks and cleanups happen. We will also see how it differs when the app mounts, unmounts, updates. This image is taken from https://github.com/donavon/hook-flow. I took the ex...

Bhanu Teja Pachipulusu's blog
29 posts
Developer, Indie Maker and Blogger. Currently building MDX.one
Checkout my portfolio
Next.js has become my go-to framework for almost every project that I make. So, I made a starter template that I can just use and get started easily.
In this article, I will show you how to use the starter template that I made and deploy it with Vercel. I will also be connecting a Postgres database which I will create on Heroku.
If this is the tech stack that you are interested in, then follow along.

Go to pbteja1998/nextjs-starter repo and click on Use this template button.

Follow the instructions and create your repo

Login to vercel and click on Import Project.

Let's import from Git Repository

Enter the URL of the repo that you created earlier and Continue.

Choose the name of the project and Deploy. We will be adding the required environment variables later.

You should see this once deployed. Open the dashboard after a successful deployment.

That's it. Your Next.js starter application has been deployed to Vercel. You can click on Visit to open the website.

You should see something like this. This home page template is taken from one of the examples in tailwindcss.com
We need a database to store users and user sessions. I will be using the Postgres database. But you can use whatever you want. If you already have a URL for your database, you can skip this step. I will be using Heroku to create a Postgres database.


Heroku Postgres addon
Heroku Postgres has a free tier available. I will be using that for the demonstration.



Click on Settings and then View Credentials.

You should be able to see the database URI now. Copy that we will be using it later. Also, note that the free tier Heroku database credentials are not permanent. They change periodically. So, when you are deploying for production, use some other database that is stable or upgrade your Heroku database to a paid plan.





NEXTAUTH_URL variable
This is the URL of the deployment.
Similarly, create all the variables that you can see in .env.example file of the repo.
SECRETsmtp.zoho.com465bhanuteja@mycompany.orgYou can follow the steps described here to create a GitHub OAuth application. While creating that OAuth app, add https://<vercel-deployment-url>/api/auth as Authorization callback URL. For example, in my case, I will add https://nextjs-starter-kit-psi.vercel.app/api/auth The rest of the fields, you can fill with anything.

After adding all the environment variables, you need to redeploy the application for the changes to take effect.

Now, your new deployment will have GitHub authentication and passwordless login with email.
I will also make a slim version of the starter kit in the future which will not require any database setup.
If you have any suggestions or face any problems setting this up, open a new issue in the repo. I will be more than happy to help you resolve those. If you like this starter kit, give a star to pbteja1998/nextjs-starter repo.
If you liked this article, check out
If you have any comments, please leave them below or you can also @ me on Twitter (@pbteja1998), or feel free to follow me.