Preview Plugin
Previewing Experiences before they are published.
The Preview Plugin allows you to assign your profile to specific audiences, experiences, and variants within preview and development contexts.
Add plugin to the plugins
prop of the NinetailedProvider
and provide an array of all Ninetailed Experience and Ninetailed Audience entries to the plugin. Ensure that you are supplying both all published and all draft entries of each to the plugin. Additionally, you should ensure that you are not instantiating the plugin in production contexts.
Installation
Add the dependency:
Then, add the plugin to the Ninetailed instance:
Conditional Instantiation
The Preview Plugin is designed to be used within preview and development contexts. This plugin does not automatically turn off in production contexts; you are responsible for instantiating the plugin only when it is required.
The above code sample shows conditionally including the plugin only when process.env.NODE_ENV !== 'production'
, but you are free to use whatever condition best identifies your non-production environments. For example, you might choose to instantiate the plugin based on whether the current visitor has turned on preview or draft mode and use this condition instead or in conjunction.
Supplying Preview Content
The Preview Plugin expects a specific format for the provided experiences
and audiences
. Use the appropriate Utility Library to map these to the required format, depending on your content source.
When fetching your Experiences and Audiences from Contentful, we provide a utility package (@ninetailed/experience.js-utils-contentful
) which handles the transformation.
Last updated