This is a Next.js project bootstrapped with create-next-app
.
Fork this repository to your GitHub account, and clone it to your local machine using git or the GitHub CLI.
Install dependencies:
npm install
# or
yarn install
At the root of your project, create an .env.local
file and copy the contents from .env.local.example
. This will provide you with a connection to an example Contentful space. You can view the live example website for this space here.
npm run dev
# or
yarn dev
Example code for the GraphQL API can be found in pages/graphql.
Example code for the REST API can be found in pages/rest.
API calls are executed at build time in getStaticProps()
on each page. Read more about getStaticProps() in Next.js.
Both code examples use @contentful/rich-text-react-renderer to render the Rich Text field nodes to React components.