RealComposer

Contentful Safe & Unsafe Practices

Direct Answer

Contentful Content Delivery API tokens only read published entries and are lower risk, but Content Preview tokens expose unpublished drafts and Content Management tokens can edit or delete content. Keep preview and management tokens on a server or edge proxy only.

Credentials & Where They Belong

Client safe
Content Delivery API token

Reads published content only. Still scope it per environment.

Server only
Content Preview API token

Reads unpublished drafts and embargoed content.

Server only
Content Management API token

Creates, edits, publishes, and deletes content.

Safe Practices

  • Inject preview tokens only in server-rendered preview routes

    Gate preview mode behind authentication and keep the token out of client bundles.

  • Use separate API keys per environment

    Staging and production should not share delivery tokens.

  • Cache delivery responses at the edge

    Published content changes rarely, so caching cuts API usage and latency.

Unsafe Practices

  • Using NEXT_PUBLIC_ or VITE_ variables for preview tokens

    Those prefixes inline values into the public bundle, leaking unreleased content.

  • Shipping a CMA token to any client

    It allows anyone to rewrite or delete your site content.

The RealComposer Pattern

Store the preview token in the vault and expose a client-token-protected preview pipeline, while published content runs through a cached public pipeline.

START BUILDING FREE

Frequently Asked Questions

Q:Is the Contentful delivery token a secret?

It is low risk because it reads published content only, but treat it as a credential and rotate it if abused.

Contentful Recipes

Related Concepts