GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - contentstack/live-preview-sdk: This SDK is responsible to establish a communication channel between the Contentstack SDK and your website, and transfer live changes to the site.

BranchesTags
Open more actions menu

Latest commit

 

History

1,734 Commits
1,734 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.husky
.husky
 
 
docs
docs
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.prettierignore
.prettierignore
 
 
.prettierrc.json
.prettierrc.json
 
 
.talismanrc
.talismanrc
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODEOWNERS
CODEOWNERS
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
babel.config.js
babel.config.js
 
 
changelog-template.hbs
changelog-template.hbs
 
 
commitlint.config.js
commitlint.config.js
 
 
eslint.config.js
eslint.config.js
 
 
main.mustache
main.mustache
 
 
mustache.ts
mustache.ts
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
tsup.config.dev.js
tsup.config.dev.js
 
 
tsup.config.js
tsup.config.js
 
 
vitest.config.ts
vitest.config.ts
 
 
vitest.setup.ts
vitest.setup.ts
 
 

Repository files navigation

@contentstack/live-preview-utils

npm License: MIT

The Live Preview Utils package runs on your website and establishes a communication channel between the page and Contentstack. This enables live content updates, edit controls, and Visual Editor UI within the preview surface.

This SDK is not a replacement for Contentstack delivery SDKs. Instead, it acts as a client-side bridge for preview and Visual Editor functionality.

Where this SDK runs

The SDK works across multiple Contentstack preview and editing experiences:

  • Live Preview: Preview entries while your site loads inside the preview panel.
  • Timeline: Preview how your site appears across future dates and scheduled updates using the same Live Preview setup.
  • Visual Editor: Enable WYSIWYG editing with your site inside an iframe. Use mode: "builder" so “Start Editing” targets Visual Editor; the SDK still works when the same site is opened in Live Preview.
  • Studio: Use alongside Studio to structure pages from reusable components, bind CMS data, and preview changes in real time. It is designed to work with Live Preview and Visual Editor on your connected site.

Requirements

  • Browser: Initialize only on the client (window must exist). Avoid calling init during server-side rendering.
  • SSR vs CSR: Defaults assume SSR-friendly behavior. For client-side rendering, pass stackSdk and set ssr: false as described in the config reference.

Installation

npm install @contentstack/live-preview-utils

Load from a CDN (advanced)

Pin the version to match your app (update 4.6.1 when you upgrade):

<script type="module" crossorigin="anonymous">
  import ContentstackLivePreview from "https://esm.sh/@contentstack/[email protected]";

  ContentstackLivePreview.init({
    stackDetails: {
      apiKey: "your-stack-api-key",
    },
  });
</script>

Tip

If you initialize the SDK using this snippet, do not initialize it again in your app bundle on the same page.

Quick start

Initialize the SDK to enable communication between your site and Contentstack:

import ContentstackLivePreview from "@contentstack/live-preview-utils";

ContentstackLivePreview.init({
  stackDetails: {
    apiKey: "your-stack-api-key",
  },
});

See the init configuration properties in docs/live-preview-configs.md for every option you can pass to init.

Configuration

You can configure the SDK using the following options:

  • enable
  • ssr
  • mode (preview vs builder)
  • editButton
  • editInVisualBuilderButton (Start Editing outside Visual Editor)
  • overlayPropagation (opt-in fallback to pierce blocking sibling overlays during hover/click detection)
  • cleanCslpOnProduction
  • stackDetails (apiKey, environment)
  • clientUrlParams — NA / EU
  • stackSdk

Full tables and examples: docs/live-preview-configs.md.

Methods and properties

  • onLiveEdit: Trigger actions on live edits
  • onEntryChange: Listen for entry updates
  • hash: Access preview state identifier
  • setPageContext: Tell Visual Builder which entry the current page renders so “Start Editing” targets the right entry (needed for custom-URL pages)
  • config: Includes runtime context (for example Live Preview / Timeline preview, Visual Editor, or independent)

The configs table of contents also lists setConfigFromParams and getGatsbyDataFormat for deeper workflows.

Advanced: stripping the SDK at build time

Set PURGE_PREVIEW_SDK or REACT_APP_PURGE_PREVIEW_SDK to "true" during build to exclude preview code from production bundles.

Note: This reduces bundle size by replacing the SDK with a lightweight stub in production.

Secret scanning

The husky pre-commit and pre-push hooks scan your changes for secrets with ggshield when it is installed. Without ggshield, the hooks print a warning and continue. To turn the scan on, install ggshield and run ggshield auth login.

Resources

  • Source: github.com/contentstack/live-preview-sdk
  • Typed API (local): npm run docs

Documentation and learning

Developers

  • Set up Live Preview for your website
  • How Live Preview works
  • Preview API
  • Set up Timeline for your website

Content managers

  • About Live Preview
  • Preview content across a Timeline
  • About Visual Editor

Studio

  • Studio
  • Get started with Studio

Academy

  • Implementing Live Preview (course)
  • Contentstack Live Preview under the hood
  • Understanding Timeline
  • Understanding Visual Editor

About

This SDK is responsible to establish a communication channel between the Contentstack SDK and your website, and transfer live changes to the site.

Topics

live-preview

Resources

Readme
MIT license

Security policy

Security policy
Activity
Custom properties

Stars

3 stars

Watchers

8 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.