Codex

Integrating with Contentful

Dependencies

Some suggested dependencies for your package.json:

"dependencies": {
  "@contentful/live-preview": "^4.6.38",
  "@contentful/rich-text-plain-text-renderer": "^17.1.0",
  "@contentful/rich-text-react-renderer": "^16.1.0",
  "@contentful/rich-text-types": "^17.1.0",
  "@contentful/vercel-nextjs-toolkit": "1.6.0",
  "contentful": "^11.7.15",
  "cf-content-types-generator": "^2.16.0"
}

Scripts

Suggested scripts to be added to you package.json for exporting schema and generating types:

"scripts": {
  "cf:export": "contentful space export --config ./contentful-cli-config.json",
  "cf:typegen": "pnpm run cf:export && cf-content-types-generator --response ./types/contentful/export.json --out ./types/contentful --typeguard --v10"
}

Configuration

Suggested configuration for Scripts to be placed in your contentful-cli-config.json to be placed in the root of your project:

{
  "spaceId": "",
  "environmentId": "development",
  "managementToken": "",
  "contentFile": "./types/contentful/export.json"
}

Important

  • Add this file to .gitignore.
  • Always use the development environment for local development.
  • Never share your management token with anyone.

Environment variables

CONTENTFUL_SPACE_ID: ""
CONTENTFUL_ACCESS_TOKEN: ""
CONTENTFUL_PREVIEW_ACCESS_TOKEN: ""
CONTENTFUL_REVALIDATE_SECRET: ""
CONTENTFUL_MANAGEMENT_TOKEN: ""
CONTENTFUL_ENVIRONMENT: ""

Last updated on

On this page