next-chop next-chop
In this repo we build a serverless recipe sharing application in React using Next.js. This is the code that we build in the Frontend Serverless with React and GraphQL course at Codemochi.
Note: This project is Version 2.0
of the project that has been updated to work with GraphCMS 2.0. The original version of the repo is located here.
Check out the staging
branch to see a step by step guide for building this application from the ground up. Each step is a commit which makes it easy to tell exactly what changed from step to step. The master
branch has two commits- the initial commit which only has a README.md file, and a merge from the staging
branch after we have built the whole application.
If you just want the finished product, you can clone this repo and the master branch will have the finished version if you pull the latest.
If you just want to run the app, check out the latest on the master
branch and then create a .env
file in the root of your file. It should have the following variables:
.env
BRANCH=master
GRAPHCMSURL=https://api-yourregion.graphcms.com/v1
GRAPHCMSPROJECTID=your-graphcms-id
domain=your-domain.auth0.com
clientId=your-auth0-clientid
clientSecret=your-auth0-clientSecret
scope='openid profile'
redirectUri=https://localhost:3000/api/callback
postLogoutRedirectUri=https://localhost:3000/
cookieSecret='one-two-three-secret-four-secret-dont-share-it-ever'
BACKEND_URL=https://localhost:3000/api/graphql
GRAPHCMS_TOKEN=your.graphcms.token
APIURL=https://www.filestackapi.com/api/store/S3
APIKEY=your-graphcms-api-key
PROJECTID=your-graphcms-projectid
CDNBASE=https://cdn.filestackcontent.com/
You can get these variables by creating an account with GraphCMS and Auth0 and we cover where to get those from and how they get loaded into this project by Next.js in steps 10 and 19, respectively.
You can start the app locally by running npm run dev
.
To serverlessly deploy, add your GitHub project to Vercel, add the environmental variables to your project, making sure to update the localhost variables to the actual endpoint that Vercel gives you, and then let it deploy.
- Auth0 for User Authentication and Authorization
- Expressive data fetching with Apollo Hooks
- SEO Optimized with Next.js
- Beautiful GraphCMS backend
- Automatic code pipeline and deployment with Vercel
This application is complex, but in the Frontend Serverless with React and GraphQL course we go through how to build this up over 10 hours of video so that you know where all of this code is coming from.
- Create the Next.js Base
- Add Styled Components
- Add Ant Design
- Add Main Layout
- Add Global Style
- Add MainHead Component
- Add Layout
- Add MainFooter
- Add MainNavbar
- Add GraphCMS
- Add WithApollo
- Add GraphQL Request Files
- Add GraphQLCodeGen
- Add RecipesList
- Add Alerts
- Add RecipeListItem
- Add Recipe Page
- Add OneRecipe
- Deploy Using Vercel
- Add Auth0
- Add Auth0 Api
- Add useFetchUser Hook
- Add Login / Logout
- Add My Recipes Page
- Add Like Button
- Add Favorites Page
- Add Create Page
- Add Create Recipe Form
- Add Form Input
- Add Form TextArea
- Add Form Ingredient
- Add Form Dropdown
- Uncontrolled vs. Controlled Components
- Add Delete Ingredient Button
- Add Form Submit Mutation
- Add Update Recipe Page
- Add Update Recipe Form
- Add Updaate Recipe Mutation
- Add Delete Recipe Button
- Add GraphQL Proxy
- Lock down GraphCMS Api
- Add Banned Mutation Check
- Add Verify User Check
- Add Verify User Permissions Check
- Add Picture Uploader
Questions? Problems? Hit me up at @codemochi on twitter or open up an issue on this Github repo and I'll get to it ASAP!