Vercel Content Link, formerly known as Vercel Visual Editing is a feature within the Vercel site preview that adds a clickable link to any content powered by a Builder data model on your site.
Click this link to go to the corresponding content entry within Builder. When you set this up in your project, an Open in Editor link for that piece of content displays, as in the following image.
The first requirement to using Vercel Content Link in your Builder-powered Next.js site is to have something on your site powered by a Builder Data model.
Next, use the Builder v3 Content API. Upgrade your React SDK to the latest version if your version does not support the apiVersion
setting.
npm update @builder.io/react@latest
With an updated SDK version that supports the Builder v3 content API, add the following to your Next.js project.
- Better support for localization (coming soon): The content API will provide improved support for localization, including querying based on localization features.
- Support for multi-level nested references (coming soon): The content API will allow you to query, resolve, and return content that has nested references of other contents and symbols.
import { builder } from "@builder.io/react";
builder.init('YOUR_BULDER_PUBLIC_API_KEY');
builder.apiVersion = "v3";
When making the call to fetch the data from Builder, include the vercelPreview
parameter and set it to true
.
Make sure to include the logic that only sets this flag to true
when Vercel is in preview mode so your production deployments do not have the additional metadata that is added to make the Edit button display.
const content = await builder.getAll("SOME_DATA_MODEL_NAME", {
options: {
vercelPreview: process.env.VERCEL_ENV === 'preview',
},
});
For more detail, read Vercel's documentation on Visual Editing.