[[TOC]]
The Live Preview Plugin is used for real-time transmission of data from content object forms, allowing the end application to display content changes live. The plugin generates links that let you open drafts of your pages directly from the editor with a live streaming preview. It works best with Next.js-based sites.
While editing your objects, you will now have access to new action on the right hand-side. Live preview - opens a preview of the latest content on your form
Example:
Imagine you've already have draft for a blog post, but now you want to make some updates. Instead of saving object form right away, you can use the Live Preview button. This lets you see your changes on the website before they will be saved.
To start, you may want to use http://localhost:3000 to easily navigate between Flotiq and your local development environment. This will be accessible to all developers working on the site locally. Once you have your page deployed and publicly visible, you should change this URL.
This key grants access to view live preview data on your website. Ensure that you define it in your application's environment variables. Without validating this key, everybody can see your live preview data.
Flotiq API key used to authorize websocket connection.
Specify the types of content for which you want the plugin to generate links.
Define the URL template for your content pages. For example, you might use /post/{slug}, where {slug} corresponds to a specific field in your content type, such as the post's title or ID. You can also use nested fields, like {internal.createdAt}, or list fields, such as {addresses[0].city}. This flexibility allows you to customize how your content URLs are structured.
You can integrate live preview functionality into any project by responding to events sent by the Live Preview plugin during content editing. We've prepared a Next.js integration that allows you to add live preview support to your project in just a few steps.
Documentation and setup instructions for integrating it into your Next.js project can be found in the @floiq/nextjs-live-preview package.
yarn- to install dependenciesyarn start- to start development mode - rebuild on file modifications- update your
plugin-manifest.jsonfile to contain the production URL and other plugin information yarn build- to build plugins
Dev environment is configured to use:
prettier- best used with automatic format on save in IDEeslint- it is built into bothstartandbuildcommands
The plugins are built into a single dist/index.js file. The manifest is copied to dist/plugin-manifest.json file.
Warning: While developing, you can use https://localhost:3053/plugin-manifest.json address to load the plugin manifest. Make sure your browser trusts the local certificate on the latter, to be able to use it e.g. with https://editor.flotiq.com
Hint: You can use localhost url from development mode https://localhost:3053/index.js
- Open Flotiq editor
- Open Chrome Dev console
- Execute the following script
FlotiqPlugins.loadPlugin('plugin-id', '<URL TO COMPILED JS>')
- Navigate to the view that is modified by the plugin
- Open Flotiq editor
- Open Chrome Dev console
- Paste the content of
dist/index.js - Navigate to the view that is modified by the plugin
Hint: You can use localhost url from development mode https://localhost:3053/plugin-manifest.json
- Open Flotiq editor
- Add a new plugin and paste the URL to the hosted
plugin-manifest.jsonfile - Navigate to the view that is modified by the plugin



