contentful-nextjs

작성자: contentful

기존 Next.js 프로젝트에 Contentful을 추가하고 구성합니다. JavaScript SDK 설치, 환경 변수 구성, 프로덕션 및… 생성을 다룹니다.

npx skills add https://github.com/contentful/skills --skill contentful-nextjs

Contentful Next.js

Use this skill to integrate Contentful into an existing Next.js application.

Contentful is a headless, API-first CMS (composable content platform) that lets Next.js apps fetch structured content through delivery and preview APIs.

Scope

  • Next.js App Router and Pages Router.
  • Published content delivery (CDA).
  • Preview content delivery with Draft Mode (CPA).
  • Environment variable and client setup patterns.
  • Environment alias-aware setup for stable deployment paths.

Not in scope

  • Personalization/optimization implementations.
  • Studio Experiences SDK setup.
  • Full content-model strategy design.

Contentful MCP note

  • If the user wants easier agent-driven interaction with Contentful during setup, suggest the Contentful MCP server docs: https://www.contentful.com/developers/docs/tools/mcp-server/.
  • Keep this skill focused on Next.js implementation. MCP guidance complements setup but does not replace app-side client wiring.

Project state

echo "=== Contentful packages ===" && node -e "try{const p=require('./package.json');const d={...p.dependencies,...p.devDependencies};const c=Object.entries(d).filter(([k])=>k.includes('contentful'));console.log(c.length?c.map(([k,v])=>k+'@'+v).join('\n'):'(Contentful SDK not installed)')}catch{console.log('(no package.json)')}" 2>/dev/null
echo ""
echo "=== Contentful env vars ===" && grep -h CONTENTFUL .env.local .env 2>/dev/null | sed 's/=.*/=<set>/' || echo "(no Contentful env vars found in .env.local or .env)"
echo ""
echo "=== Router type ===" && ([ -d "app" ] && echo "App Router detected (app/ directory exists)" || ([ -d "pages" ] && echo "Pages Router detected (pages/ directory exists)" || echo "(could not detect router type)"))

Workflow

  1. Check the latest stable Next.js release online at https://github.com/vercel/next.js/releases when version-specific guidance is needed.
  2. Confirm Next.js project structure (App Router vs Pages Router).
  3. Configure required env vars. If they are missing, ask the user to add them to .env.local before continuing, and explain where to find each value.
  4. Install and initialize contentful SDK.
  5. Implement published-content fetching.
  6. Add preview-aware behavior for Draft Mode.
  7. Validate with a minimal test route/page and troubleshooting checklist.

Version-check policy

  • Do not rely on memory for "latest Next.js version" claims.
  • Verify against https://github.com/vercel/next.js/releases before recommending upgrades, compatibility workarounds, or version-specific fixes.
  • Treat the latest non-prerelease tag as default unless the user explicitly asks for canary/RC guidance.

Required environment variables

  • CONTENTFUL_SPACE_ID - Find it in the Contentful URL (/spaces/<SPACE_ID>/...) or in Space settings -> API keys.
  • CONTENTFUL_ACCESS_TOKEN - CDA token from Space settings -> API keys.
  • CONTENTFUL_PREVIEW_ACCESS_TOKEN (for preview workflows) - CPA token from Space settings -> API keys.

Creating an API key in Contentful provides both tokens needed here:

  • CDA token -> CONTENTFUL_ACCESS_TOKEN
  • CPA token -> CONTENTFUL_PREVIEW_ACCESS_TOKEN

Defaults

  • If the user does not specify router type, default to Next.js App Router guidance.
  • Use CDA host for normal delivery.
  • Use preview.contentful.com and preview token when Draft Mode is enabled.
  • Prefer an environment alias (for example master) as the client environment value to decouple runtime clients from release environment IDs.
  • Keep Contentful client creation in a shared utility module.

References

contentful의 다른 스킬

contentful-custom-app-enhancement
contentful
기존 Contentful App Framework 커스텀 앱을 고객의 저장소에서 개선, 디버깅 및 확장합니다. 사용자가 버그 리포트, 기능 요청 등을 제공할 때 사용하세요.
official
contentful-custom-app-from-scratch
contentful
고객의 자체 리포지토리나 워크스페이스에 새로운 Contentful App Framework 커스텀 앱을 설계, 스캐폴딩, 구축 및 검증합니다. 사용자가 다음을 생성하려는 경우 사용하세요…
official
contentful-help
contentful
Contentful 주제를 진단, 구성 및 조회합니다. 트리거 키워드: contentful help, contentful doctor, contentful setup
official
game-jam
contentful
브라우저 기반 테트리스 게임을 설계, 계획, 구축하는 과정을 안내하는 가이드 게임 제작 스킬입니다. 모든 SDK 기본 요소(askUser 등)를 시연합니다.
official
get-to-know-you
contentful
사용자를 알아가는 장난기 가득한 인터뷰로, 프로필 트레이딩 카드를 생성합니다. 사용자가 자신을 소개하고 싶을 때 또는 분위기를 전환하고 싶을 때 사용하세요.
official
contentful-api
contentful
포괄적인 Contentful REST API 가이드. 게시된 콘텐츠를 가져오기 위한 Content Management API(CMA) 및 Content Delivery API(CDA)를 다룹니다.
official
contentful-guide
contentful
Contentful의 핵심 개념을 설명하고 사용자를 적절한 구현 스킬이나 문서로 안내합니다. 사용자가 개념적 질문을 하거나 용어가 필요할 때 사용하세요.
official
contentful-migration
contentful
Contentful 콘텐츠 모델 마이그레이션 스크립트를 작성하고 실행하는 방법으로, contentful-migration 라이브러리와 Contentful CLI를 사용합니다. 생성, 편집, 삭제 등을 다룹니다.
official