name: contentstack-nuxt description: Use when wiring Contentstack tokens, region/endpoints, the Delivery SDK plugin, composable queries, or live preview in this Nuxt kickstart.
Contentstack + Nuxt – Contentstack Kickstart: Nuxt
When to use
- Setting or changing Contentstack-related environment variables
- Initializing or modifying the stack / live preview setup
- Fetching content or adjusting the
pagecontent type query - Updating TypeScript models for Contentstack entries in
types.ts
Instructions
Environment variables
- Template:
.env.example. Keys use theNUXT_CONTENTSTACK_*prefix and map intoruntimeConfig.publicinnuxt.config.ts(apiKey,deliveryToken,previewToken,environment,preview,region, plus optional endpoint overrides). - Optional:
NUXT_CONTENTSTACK_CONTENT_DELIVERY,NUXT_CONTENTSTACK_PREVIEW_HOST,NUXT_CONTENTSTACK_CONTENT_APPLICATIONfor non-default endpoints (internal testing).
Region and endpoints
nuxt.config.tsusesgetRegionForStringandgetContentstackEndpointsfrom@timbenniks/contentstack-endpointsto derive delivery/preview/application hosts when env overrides are absent.
SDK and live preview (plugin)
app/plugins/contentstack.tsbuilds the stack with@contentstack/delivery-sdk, enableslive_previewwhenpreviewis true, and on the client initializes@contentstack/live-preview-utils(builder mode, edit button).- Injected on the Nuxt app:
stack,preview,ContentstackLivePreview(access viauseNuxtApp().$stack, etc.).
Fetching pages
app/composables/useGetPage.tsqueries content typepagewithwhere("url", QueryOperation.EQUALS, url), usesuseAsyncDatawith a keypage-${url}, applieslivePreviewQueryfrom the route when preview is on andlive_previewappears in the query, and callscontentstack.Utils.addEditableTagsfor preview tagging when enabled.
Root UI and preview refresh
app/app.vuecallsuseGetPage("/"), imports live-preview helpers, and on mount callslivePreview.onEntryChange(refresh)when preview mode is active.
Types
- Shared entry shapes:
types.ts(Page, blocks,File, etc.). Keep these aligned with your stack’s content types.
Stack setup (humans)
- README describes Contentstack CLI login, seeding
contentstack/kickstart-stack-seed, creating delivery/preview tokens, and enabling Live Preview for the preview environment.