Example PWA project leveraging Next.js for frontend, with vercel serverless function for APIs + free MongoDB Atlas cluster. The project uses:
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- NodeJS >= 10 -- Official download
- Yarn >= 1.16.0 -- Official download
-
Create an
.env
file based on the.env.example
file -
For
GOOGLE_OAUTH_ID
andGOOGLE_OAUTH_SECRET
, follow [Google oAuth docs] to get your own Google oAuth AppId and secret. This is how the values look like:GOOGLE_OAUTH_SECRET=tfmG-_kIcxqn2drkMMSsdLH GOOGLE_OAUTH_ID=3459784788234-va9877zx89asd8as8d8asdg.apps.googleusercontent.com
-
For
JWT_SECRET
you can generate a random, secure string. This is used for signing JWT bynext-auth
-
For
MONGO_CONNECTION_STRING
, you can get one from free using MongoDB Atlas. This is how the values look like:MONGO_CONNECTION_STRING=mongodb+srv://root:password@cluster0.d7sa9s.mongodb.net/dbname?retryWrites=true&w=majority
-
Install dependencies using yarn
yarn install
-
Start development server
yarn dev
The tests are run using jest
. Simply run yarn test
to run the tests.
To get test coverage, run yarn test:coverage
There are many ways to deploy to vercel
as documented in their docs
Remember to populate the environment variables for your vercel deployment as well! Refer to the .env.example
file for all keys and values.