Get the env values
How to get the environment variables in your project
Obtain GOOGLE_CLIENT_ID
and GOOGLE_CLIENT_SECRET
from Google:
To obtain the values for the above variables, we need to create an OAuth client on google. Just follow the next steps:
- Go to Google Developer Console
- Create a new project by clicking on the top left corner of the screen, next to the Google Cloud Platform logo.
- Once the project is created, click on the project name and then on the
Credentials
tab on the left side of the screen. - Click on Create Credentials and select OAuth client ID. On
application type
we will select Web Application, then give it any name you want to reference it. - Now we need to add the
JavaScript Authorized Origins
, click on “Add URI” and introduce the URL of your app, if you are using localhost on the default port it will behttp://localhost:3000
- Last thing would be add a
Authorized URI Redirects
, click on “Add URI” and introduce the URL of your app followed by /api/auth/callback/google so it would look like thishttp://localhost:3000/api/auth/callback/google
- Now click on Add and it will show the
Client ID
and theClient Secret ID
so copy the values and paste it into the corresponding variables on the.env
file.
Google Provider would be successfully configured. If you wish, you can read more information about it on the Google Provider Section of NextAuth Docs
Github
Obtain GITHUB_CLIENT_ID
and GITHUB_CLIENT_SECRET
from Github:
To obtain the values for the above variables, we need to create an OAuth App, Just follow the next steps:
- Go to Github App Settings
- Click on
Oauth Apps
then onNew OAuth App
- On
Application name
, we will introduce the name of our App, this is the name that will show when Github request access to their information during the Github sign in. - On
Homepage URL
goes the Homepage URL of our app for examplehttp://localhost:3000
. - On
Authorization callback URL
we need to introduce our App URL followed by /api/auth/callback/github. so it would look like this:http://localhost:3000/api/auth/callback/github
- After create it we can then copy the
Client ID
, and generate aClient Secret
and paste it into the corresponding variables on the.env
file
Github Provider would be successfully configured. If you wish, you can read more information about it on the Github Provider Section of NextAuth Docs
Resend
Resend is necessary for the emails of your app. To get the resend values you need to follow the next steps:
- Go to Resend
- Create a new account or login with your existing account.
- You will need to add a domain name, and set the DNS records to verify the domain.
- Once the domain is verified, go to the
API Keys
- Create a new API key and copy the value into the
RESEND_API_KEY
variable on the.env
file. - Fill the
EMAIL_FROM
variable with the email you want to send the emails from. It can beanything@yourverifieddomain.tld
for examplecustomers@mail.shipit.so
Resend would be successfully configured.
Stripe
Stripe is a payment service that you can use to receive payments from your users. To fill the necessary values you need to follow the next steps:
- Go to Stripe
- Create a new account or login with your existing account.
- Once you are logged in, go to the
Developers
tab and then to theAPI keys
tab. - Copy the
Publishable key
and paste it into theNEXT_PUBLIC_STRIPE_PUBLIC_KEY
variable on the.env
file. - Copy the
Secret key
and paste it into theSTRIPE_SECRET_KEY
variable on the.env
file.
Now we need to get the webhook secret:
- Install the Stripe CLI by following the instructions on the Stripe CLI documentation
- Run the following command to login to your Stripe account:
- Run the following command to listen for events on your Stripe account:
- Copy the webhook secret and paste it into the
STRIPE_WEBHOOK_SECRET
variable on the.env
file.
Stripe would be successfully configured.
Crisp (Optional)
Crisp is a chat service that you can use to give customer support to your users. The free plan should be more than enough to get you started. To add it to your project you need to follow the next steps:
- Go to Crisp and create an account
- Once you are logged in, go to the
Settings
tab and then to theWebsite Settings
tab. - Select your website
- Go to
Setup instructions
and copy theWEBSITE_ID
value and paste it into theNEXT_PUBLIC_CRISP_WEBSITE_ID
variable on the.env
file.
Crisp would be successfully configured.