This demo application is a small re-implementation of some GitHub pages / functionality built using their GraphQL API.
Netlify URL: https://next-react-query-tailwind.starter.dev
Download or clone the starter.dev-showcases repository from https://github.com/thisdot/starter.dev-showcases
git clone https://github.com/thisdot/starter.dev-showcases.git
gh repo clone thisdot/starter.dev-showcases
Open the project root directory in your terminal and navigate to the next-react-query-tailwind
showcase. Run yarn
to install the dependencies.
cd next-react-query-tailwind
yarn
The src/lib/graphql.ts
file gets generated by graphql-code-generator
when you run yarn codegen
. This file includes types, queries, and mutations, and react-query
specific hooks for interacting with the GitHub GraphQL API.
This gets run automatically before running yarn dev
and yarn build
.
yarn codegen
The repository comes with an .env.example
file that includes all the environment variables that are required for the application to run.
NEXT_PUBLIC_GRAPHQL_ENDPOINT
- The url to the Next API function that proxies the applications GraphQL requests to the GitHub GraphQL API.NEXTAUTH_URL
- The url for our application used by Next AuthGITHUB_GRAPHQL_ENDPOINT
- The url to the GitHub GraphQL APIGITHUB_CLIENT_ID
&GITHUB_CLIENT_SECRET
- The OAuth credentials for our application auth that need to be setup in GitHubJWT_SECRET
&JWT_SIGNING_KEY
&JWT_ENCRYPTION_KEY
- These are generated keys used to encrypt the JWT that gets passed to our graphql proxy endpoint.
To use this app and authenticate with GitHub, we need to setup the OAuth credentials in GitHub.
- Navigation to the GitHub settings page.
- Click the
Developer settings
link in the sidebar. - Click the
OAuth Apps
link in the sidebar. - Click the
New OAuth App
button at the top right of the page.
Register a new OAuth application form details
- Application name - Enter a name for the application
- Homepage URL - Enter the url of the Next application. (If running locally
http://localhost:3000
otherwise the url of the application on the interenet) - Authorization callback URL - Enter the url of the applications oauth callback. (If running locally
http://localhost:3000
otherwise the url of the Next application)
After registering your OAuth application, add the generated client id and secret to a .env
file for the project.
GITHUB_CLIENT_ID=xxx
GITHUB_CLIENT_SECRET=xxx
There is some pre generated encryption keys provided in the .env.example
file but if you want to generate new ones this is for reference on how to do it. See: next-auth #484
openssl rand -base64 32
npx node-jose-tools newkey -s 256 -t oct -a HS512
npx node-jose-tools newkey -s 256 -t oct -a A256GCM
Start the development server
yarn dev
Open your browser to http://localhost:3000
This demo app gets deployed to Netlify on changes to the main
branch.