- Simple Next.js app that uses the OpenAI API to generate text based on a prompt.
git clone git@github.com:boolfalse/nextjs-sample.git && cd nextjs-sample
- Install dependencies (Node.js v18+)
- Get the Google OAuth credentials.
- Create a new project in the Google Cloud Console
- Set up the OAuth consent screen
- Create an OAuth client ID
- Add the authorized redirect URI as
http://localhost:3000/api/auth/callback/google
- Setup the
.env file as described in .env.example
OAUTH_GOOGLE_CLIENT_ID="************-********************************.apps.googleusercontent.com"
OAUTH_GOOGLE_CLIENT_SECRET="******-****************************"
OAUTH_GOOGLE_REDIRECT_URI="http://localhost:3000/api/auth/callback/google"
- Get the MongoDB credentials:
- Create a new project in the MongoDB Cloud
- Create a new cluster
- Create a new database user
- Setup the
.env file as described in .env.example
MONGODB_DATABASE="<database>"
MONGODB_URI="mongodb+srv://<username>:<password>@<cluster-url>/<database>?retryWrites=true&w=majority"
- Setup NextAuth credentials:
- Run the following command:
- Setup the
.env file as described in .env.example
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_URL_INTERNAL="http://localhost:3000"
NEXTAUTH_SECRET="********************************************"
- Run the app:
- Open the app in the browser.