Contentstack provides the Live Preview SDK to establish a communication channel between the various Contentstack SDKs and your website, transmitting live changes to the preview pane.
The "@contentstack/live-preview-utils" npm package is a highly effective tool designed to enhance the capabilities of Contentstack, a leading headless CMS, by enabling live preview functionalities. This utility module plays a crucial role in streamlining the development process by allowing developers to instantly view changes made in the Contentstack content management system directly on their websites or applications. This instant feedback can significantly boost productivity and accuracy during the development phase. By incorporating live previews, developers can ensure that their content looks and behaves as expected in a real-world scenario, reducing the likelihood of errors and rework after deployment.
To take advantage of these capabilities, developers can easily integrate this utility into their projects by using the command "npm install @contentstack/live-preview-utils". This simple installation process adds the Live Preview SDK to their development environment, setting up a seamless communication channel between Contentstack's SDKs and the user's application. This integration not only facilitates real-time content updates directly in the preview pane but also enhances the overall development workflow, making it more efficient and less prone to errors.
The benefits of using "@contentstack/live-preview-utils" extend beyond just real-time content updates. It also supports a more collaborative and agile development environment. Teams can work together more effectively, as content creators and developers can simultaneously view changes and iterate on them in real time. This collaboration can lead to a more dynamic and flexible content strategy, where adjustments can be made quickly and efficiently, ensuring that the final product is of the highest quality. The utility also supports various frameworks and platforms, making it a versatile addition to any development stack that uses Contentstack as its CMS.
Contentstack provides the Live Preview SDK to establish a communication channel between the various...
Read moreThe Content Management API is used to manage the content of your Contentstack...
Read moreThis Package converts Html Document to Json and vice-versa...
Read moreGatsby source plugin for building websites using Contentstack as a data...
Read moreThe Extensions SDK allows you to extend Contentstack’s UI by helping you create Custom Fields,...
Read moreGatsby source plugin for building websites using Contentstack as a data...
Read moreThe Contentstack App SDK allows you to customize your Contentstack applications...
Read moreCore dependencies of this npm package and its dev dependencies.
just-camel-case, morphdom, mustache, uuid, @babel/core, @babel/preset-env, @testing-library/jest-dom, @types/jest, @types/mustache, @types/uuid, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, babel-loader, css-loader, eslint, eslint-config-prettier, husky, jest, jest-fetch-mock, mini-css-extract-plugin, prettier, prettier-eslint, style-loader, ts-jest, ts-loader, typedoc, typescript, webpack, webpack-cli, webpack-dev-server, webpack-merge
A README file for the @contentstack/live-preview-utils code repository. View Code
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest.
Contentstack provides the Live Preview Utils SDK to establish a communication channel between the various Contentstack SDKs and your website, transmitting live changes to the preview pane. Read More.
To install the package via npm, use the following command:
npm install @contentstack/live-preview-utils
Alternatively, if you want to include the package directly in your website HTML code, use the following command:
<script src="https://unpkg.com/@contentstack/live-preview-utils@1.4.2/dist/index.js"></script>
Since the Live Preview Utils SDK is responsible for communication, you need to only initialize it. Use the following command to initialize the SDK:
import ContentstackLivePreview from "@contentstack/live-preview-utils";
ContentstackLivePreview.init({
stackDetails: {
apiKey: "your-stack-api-key",
},
});
Alternatively, if you want to initialize the SDK directly inside the HTML tag, use the ContentstackLivePreview.init() method as follows:
<script>
ContentstackLivePreview.init({
stackDetails: {
apiKey: "your-stack-api-key",
},
});
</script>
Live Preview provides edit tags that allow you to edit your content in real-time. Live edit tags are identified as the data-cslp attribute within the HTML tags. The styles for the live edit tags are available in the @contentstack/live-preview-utils/dist/main.css file.
To use live edit tags within your stack, you need to include them in your main index.js file as follows:
import "@contentstack/live-preview-utils/dist/main.css";
MIT License
Copyright © 2024 Contentstack. All Rights Reserved
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.