content/guides/02.content/8.visual-editor/2.studio-module.md
The visual editor module enables content editors to render their website within the Directus Studio, navigate around within the site, and make edits to content in place.
::callout{icon="material-symbols:info" color="info"} Visual editing also works in the Live Preview pane on item detail pages. This gives the same editing experience without switching modules. ::
Navigate to Settings → Visual Editor and add the URL of your website that you want to visually edit. If you have multiple websites, add multiple URLs.
Be sure to enable the Visual Editor from the Modules section of the settings page so it shows up in your project's module bar.
The URL field supports a {{$version}} template variable. When included, the Visual Editor will pass the currently selected version key to your website, enabling version-aware previews.
https://your-site.com/preview?version={{$version}}
{{$version}} resolves to main.To ensure version-aware editing functions correctly, verify the following configuration steps:
1. Frontend Integration
{{$version}} in the URL field. If omitted, the version selection dropdown will not appear in the Visual Editor toolbar./items/posts/42?version=draft). Without this, the site will continue to display "Main" content regardless of your selection.2. Environment Configuration
Update your Directus instance environment variables to authorize the connection and ensure content refreshes:
| Variable | Required Value | Purpose |
|---|---|---|
CONTENT_SECURITY_POLICY_DIRECTIVES__FRAME_SRC | "<your-website-url>" | Allows your website to be embedded within the Directus Studio iframe. |
CACHE_AUTO_PURGE | true | Ensures the preview reflects changes immediately after saving edits. |
::callout{icon="material-symbols:warning-rounded" color="warning"}
Critical Setup: Your website will be unable to communicate with Directus if the CONTENT_SECURITY_POLICY_DIRECTIVES__FRAME_SRC directive is missing.
Additionally, without CACHE_AUTO_PURGE enabled, the Visual Editor will continue to display stale data until the cache naturally expires.
::
Once your URLs are set up, navigate to the visual editor module by selecting it from module bar. Your first entered URL will render in the module.
Navigating between different added URLs can be done by clicking the dropdown in the top toolbar.
Hovering over an editable item will highlight it within the module.
Click the :icon{name="material-symbols:edit"} icon in the toolbar will highlight all the editable items on the page.
Clicking the :icon{name="material-symbols:edit"} beside an editable element will open an editor in either a drawer, modal, or popover depending on which mode was specified in the elements data-directus attribute on the frontend.
Once you are done editing your item, click the save button and your website will refresh to show your changes.
When a URL includes the {{$version}} variable, a version dropdown appears in the toolbar of the Visual Editor.
The dropdown lists:
If your website URL contains a version key that doesn't match "main" or "draft" (e.g. from a custom query parameter), it will also appear as a dynamic option in the dropdown.
When a version other than main is selected:
::callout{icon="material-symbols:info-outline"}
The version dropdown requires the user to have read permission on directus_versions. Editing in a version additionally requires create or update permission on directus_versions.
::
Editable elements are gated by field-level permissions. When visual editing is active, Directus validates each element against the current user's access before making it interactive:
directus_versions permissions.Elements that fail permission checks remain completely inert — no overlay, no hover effect, no click handler.
When AI Assistant is available, you can add visual elements as context for AI conversations. Hover over an editable element and click the AI icon to select it, then open AI Assistant to send your message with the element as context.
For more details on using context attachments, see Adding Context.