Preview Button Multi-domain logo

Preview Button Multi-domain

By Brain Station 23

A Strapi plugin that extends the Preview Button to support multiple domains and locales. It automatically generates preview URLs using the correct frontend domain, making localized content preview easier across multiple websites and regional versions.

Latest version

v1.0.0

released September 3, 2026

npm install preview-button-multidomain
Logo for Strapi preview button plugin

Strapi Preview Button Multidomain

A plugin for Strapi CMS that adds a preview button and live view button to the content manager edit view multi domain and multi locals.

preview-button-multidomain latest npm version Strapi supported version Github preview button multi domain

Screenshot for Strapi preview button plugin

preview-button-multidomain

Depends on: strapi-plugin-preview-button@^3 (required peer; does not replace it).
Upstream: mattmilburn/strapi-plugin-preview-button

Features

  • Works with upstream Open draft preview, Copy link, and live view (does not replace those buttons)
  • Extends strapi-plugin-preview-button for multi-domain / multi-locale hosts
  • Map locales (and slugs) → frontend hosts via configurable domains[]
  • One host for several locales, or separate hosts per locale/market
  • Exact .env keys on domains[].env (no auto-prefix)
  • Optional defaultEnv when locale/slug do not match
  • Locale match first, then slug (slug can override); null-safe {host} replace
  • Single consumer config: contentTypes on this plugin, mirrored onto preview-button at bootstrap
  • Bundler-safe: server resolves env → URLs; admin fetches public config

Prerequisites

Install and enable strapi-plugin-preview-button first. This extender only chooses the host; without upstream, there are no preview buttons. Peer install does not auto-enable it in Strapi — both plugins must appear in config/plugins.

Install

npm install preview-button-multidomain strapi-plugin-preview-button@^3

Docs: README · Release notes

Configure config/plugins

1. Primary example

Mix patterns in one domains list: one host for several languages (DACH), plus another host for English.

URL partWho covers it
HostThis plugin — {host} from the matched domains row
Path prefix (/de_DE/, /de_AT/, …)Not this plugin — {localePath} (or another mapped entry field) in the template
Page slugUpstream preview-button via {slug}
// config/plugins.ts
export default ({ env }) => ({
  'preview-button-multidomain': {
    enabled: true,
    config: {
      domains: [
        {
          env: 'STRAPI_ADMIN_DOMAIN_DACH',
          locales: ['de-DE', 'de-AT', 'de-CH'],
          // host matching only — does NOT insert /de_AT/ into the URL
          slugs: ['de_DE', 'de_AT', 'de_CH'],
        },
        {
          env: 'STRAPI_ADMIN_DOMAIN_ENGLISH_1',
          locales: ['en-GB'],
          slugs: ['en'],
        },
      ],
      defaultEnv: 'STRAPI_ADMIN_DOMAIN_DACH',
      contentTypes: [
        {
          uid: 'api::page.page',
          draft: {
            // {host} = this plugin; {localePath}/{slug} = upstream/entry fields
            url: `{host}/{localePath}/{slug}?secret=${env('PREVIEW_SECRET')}&status=draft`,
          },
          published: {
            url: `{host}/{localePath}/{slug}`,
          },
        },
      ],
    },
  },

  // Required — npm dependency does not auto-enable Strapi plugins
  'preview-button': true,
});
STRAPI_ADMIN_DOMAIN_DACH=https://mydomain.com
STRAPI_ADMIN_DOMAIN_ENGLISH_1=https://english.example.com
PREVIEW_SECRET=your-preview-secret

Prefer STRAPI_ADMIN_* for admin-related hosts. There is no auto-prefix: env is the exact process.env key.

This plugin does not auto-convert de-AT → /de_AT/.

Single locale, single slug (one language → one host):

{
  env: 'STRAPI_ADMIN_DOMAIN_GERMAN',
  locales: ['de-DE'],
  slugs: ['de_DE'],
},

2. More hosts (optional)

Add more rows the same way — each env is a different host:

domains: [
  {
    env: 'STRAPI_ADMIN_DOMAIN_DACH',
    locales: ['de-DE', 'de-AT', 'de-CH'],
    slugs: ['de_DE', 'de_AT', 'de_CH'],
  },
  {
    env: 'STRAPI_ADMIN_DOMAIN_ENGLISH_1',
    locales: ['en-GB'],
    slugs: ['en'],
  },
  {
    env: 'STRAPI_ADMIN_DOMAIN_FRENCH',
    locales: ['fr', 'fr-FR'],
    slugs: ['fr'],
  },
],
defaultEnv: 'STRAPI_ADMIN_DOMAIN_DEFAULT',
STRAPI_ADMIN_DOMAIN_DACH=https://mydomain.com
STRAPI_ADMIN_DOMAIN_ENGLISH_1=https://english.example.com
STRAPI_ADMIN_DOMAIN_FRENCH=https://french.example.com
STRAPI_ADMIN_DOMAIN_DEFAULT=https://www.example.com

Resolution rules

  1. Match data.locale against domains[].locales
  2. Then match data.slug against domains[].slugs (slug can override; host matching only — does not write path prefixes)
  3. Else use defaultEnv URL when set
  4. Missing env values are skipped (domain omitted); unmatched entries do not inject undefined into URLs

Dual-config fallback

If extender contentTypes is empty, contentTypes already configured on preview-button still work. Prefer the single extender config above.

Migration from preview-button-before-build

  1. Replace package / plugin key with preview-button-multidomain
  2. Move host selection into config.domains (+ defaultEnv) instead of hard-coded DE/AT/CH envs
  3. Move contentTypes onto this plugin’s config (optional but recommended)
  4. Keep 'preview-button': true

Develop

npm run build
npm run verify
npm test
Required dependency (npm)strapi-plugin-preview-button (^3)
Upstream sourcemattmilburn/strapi-plugin-preview-button
This plugin (npm)https://www.npmjs.com/package/preview-button-multidomain
READMEhttps://github.com/BrainStation-23/strapi-preview-multidomain-plugin/blob/main/README.md
Release noteshttps://github.com/BrainStation-23/strapi-preview-multidomain-plugin/blob/main/RELEASE.md
Issueshttps://github.com/BrainStation-23/strapi-preview-multidomain-plugin/issues

Organization: BrainStation-23
Author: Abu Sayed (sayedbs)
Repository: BrainStation-23/strapi-preview-multidomain-plugin
Release notes: https://github.com/BrainStation-23/strapi-preview-multidomain-plugin/blob/main/RELEASE.md

Submit your content

Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.

Submit
Submit your content