One slug per product and collection, identical in every language — enforced on the server for every API client, and shown in the React dashboard as a single slug field instead of one per language tab.
Vendure stores a slug on every translation row, so each language can have its own. A storefront
rarely wants that: findOneBySlug matches a slug in any language, so per-language slugs are only
more URLs to keep in sync. And the dashboard's stock slug field generates a slug only when an entity is
created — add a language to an existing collection and the new translation is saved with
slug: '' (vendurehq/vendure#5476). This plugin
closes that gap on both sides.
Not for shops that intentionally give each language its own slug (/uk/sukni, /en/dresses).
The plugin overwrites a divergent slug with the canonical one on every write, and there is no
per-language switch.
Compatible with Vendure ^3.7.0.
Install · Usage · What it looks like · How it works · Options · Custom slug strategy · GraphQL surface · Backfilling existing rows · Limitations
@vendure/core and @nestjs/* are peer dependencies — the plugin uses the copies already in your
project. The dashboard extension additionally uses @vendure/dashboard and the React libraries it
ships with; those peers are optional, so a server without the React dashboard needs none of them.
That is all: no entities, so no migration; no jobs; no environment variables. If you use the React
dashboard, its Vite plugin (vendureDashboardPlugin) discovers the extension from the package on its
own — restart the dashboard dev server or rebuild it.
The product and collection detail pages get one slug field. Whichever content language is active, it shows the same value, and a change made in any language is written to all of them.

Adding a language to an existing collection: the new translation already carries the slug and is saved
with it. With the stock field, it would be saved with slug: ''.

Unlike the stock field, it also generates a slug on an existing entity: a product imported or saved without one gets a slug as soon as its name is edited.

The edit button switches the field to manual entry (the lock switches it back); the refresh button regenerates the slug from the current name, also on an entity that has no slug yet.

A global interceptor acts on five Admin API mutations — createProduct, updateProduct,
updateProducts, createCollection and updateCollection — and rewrites input.translations
before the core resolver runs. The unified slugs travel in the mutation's own transactional write:
no follow-up write, no event subscriber, no job, and nothing to undo if the mutation fails.
The canonical slug is, in order:
languageCode order;Every translation in the input gets the canonical slug, including one that arrived with a different
non-empty slug. On update, every existing row whose language is not in the input and whose slug
differs gets a slug-only { languageCode, slug } translation appended. That changes the slug and
nothing else: name, description and custom fields of that row stay as they are, and a language
left out of the input is never deleted.
Worth knowing:
translations key — toggling enabled, say — costs no query. Neither does a
create.translations: [] reads the existing rows and pulls any that drifted apart back onto
one slug. That is the cheapest way to repair one entity.SlugValidator runs afterwards and normalises
every translation identically, so unified slugs stay unified.The extension replaces the slug input on the product and collection detail pages. The field:
The field asks the server once per session which form fields the slug strategy watches. If that query fails, no fields are watched; auto-generation still works.
The field asks this plugin's unifiedSlugGenerate query instead of core's slugForEntity. The
configured slug strategy builds the base; core's EntitySlugService — the same service behind
slugForEntity — passes it through your core SlugStrategy and appends -1, -2… until it is
unique. With the default strategy the answer is exactly what slugForEntity would give.
SlugGenerationService is exported, so an importer or another plugin can produce the same slug the
dashboard would:
UnifiedSlugPlugin.init(options):
| Option | Type | Default | Description |
|---|---|---|---|
slugStrategy | UnifiedSlugStrategy | new DefaultUnifiedSlugStrategy() | What a generated slug says. The default is the name, as core's slugForEntity has it. |
Implement UnifiedSlugStrategy when a generated slug should say more than the name. The strategy
returns the slug's base; normalising and uniqueness stay core's.
generateBase may be async. Return '' when there is nothing to build a slug from — the plugin
then answers '' rather than inventing one.watchFormFields are react-hook-form paths in the product / collection detail form. For a relation
custom field the form holds the id under customFields.<name>Id. Values arrive in context keyed
by path; a caller without a form (an importer, a script) passes whatever it has, or {}.SlugStrategy afterwards. The default one lower-cases, strips
diacritics, drops every character outside a-z, 0-9, spaces and hyphens, and turns spaces into
hyphens — so a name in Cyrillic yields an empty slug. If your catalogue is named in Ukrainian or
another non-Latin script, transliterate in generateBase (with a library such as
slugify or slug)
and return Latin text.InjectableStrategy: the plugin calls init(injector) on bootstrap and
destroy() on shutdown, so it can resolve services such as TransactionalConnection.Admin API only. Both queries are gated by Permission.Authenticated — the same gate as core's
slugForEntity, which the dashboard field replaces.
No mutations: the slug itself is still written through core's createProduct, updateCollection and
the rest.
The plugin fixes rows when they are written; rows already in your database keep what they hold until
their entity is saved again. To fix one entity, send updateProduct / updateCollection with
translations: []. To fix them all, run backfillUnifiedSlugs once from a script next to your
Vendure config:
It boots Vendure headless from your config (bootstrapWorker, no API server, job queue not started),
so your UnifiedSlugPlugin and slug strategy are the ones used; it fails if the plugin is not in
config.plugins. It applies the same rule as the interceptor, with the default
language of the default channel, to every product and collection. Options: entityName ('Product'
or 'Collection') to do only one kind, channelToken for another channel's default language, and
logger to receive the report lines instead of console.log. In a running app,
runSlugBackfill(app, options) does the same without booting.
It prints the counts, then one line per entity that is not already on one slug, with the slugs it had:
| Outcome | Meaning |
|---|---|
FILLED | Empty slugs get the slug a sibling translation already has. No URL changes. |
REWRITTEN | A non-empty slug is replaced by the canonical one, so that URL changes. The old one is in the line if your storefront needs a redirect. |
GENERATED | No translation had a slug; one is generated by the slug strategy, with an empty context, from the default-language name, else the first name it has. |
CONFLICT | Another entity owns the slug in a language that would get it, even after this run. Left unchanged — decide by hand. |
NO_SLUG | No translation had a slug and the name yields none (e.g. a Cyrillic name under the default strategy). Left unchanged. |
The same report is returned as a SlugBackfillReport. Soft-deleted products and the root collection
are skipped, and a slug that the run itself rewrites away no longer counts as taken.
A real run is one transaction: it applies every non-conflicting change or none. It writes the
translation rows directly, so no product or collection events are published — if your search index
stores slugs, reindex afterwards (e.g. the reindex mutation of the default search plugin). A second
dry run should list only conflicts and NO_SLUG entities. Run it while the catalogue is quiet: it
takes no row locks, so an edit saved during the run can be overwritten or missed.
duplicateEntity and the CSV importer call the services
directly. Both stay consistent in practice: the duplicators derive each language's slug from that
language's own source row (slug + '-copy'), so a copy of a unified entity is unified, and an
import is as unified as its input file.SlugValidator checks uniqueness per language. If a
different entity already owns the slug in some languages but not others, core suffixes only those
(dresses-2 in en, dresses in uk). The next write through the plugin pulls them back
together; a backfill dry run finds any that are currently apart.CONFLICT that core would have allowed.See CHANGELOG.md.
MIT © Uplab
c7d7775 Thanks @brmk! - Install alongside Vendure 3.8: the @nestjs/common and @nestjs/core peers now accept ^11 || ^12, and @nestjs/graphql accepts ^13 || ^14. Vendure 3.8 moved to NestJS 12, so npm install failed with ERESOLVE against the old ^11 / ^13 ranges. Nothing changes on Vendure 3.7.a354e4d Thanks @brmk! - Add backfillUnifiedSlugs(config, { dryRun }), a function to run once from a host script. It brings products and collections saved before the plugin onto one slug per entity. It boots Vendure headless from your config, applies the same rule as the interceptor in one transaction, works on every database Vendure supports, and prints a report of what was (or, with dryRun, would be) filled, rewritten, generated, or left alone because of a conflict. It replaces the PostgreSQL queries previously shown in the README.01444f5 Thanks @brmk! - Initial release. Keeps one slug per product and collection, identical in every language: a server-side interceptor unifies the slugs of every create and update before core saves them, and the React dashboard shows a single slug field that also generates the slug on update — the stock field leaves a language added to an existing entity with an empty slug. What a generated slug says is pluggable through UnifiedSlugStrategy; SlugGenerationService and the unifiedSlugGenerate Admin API query expose it to importers and other plugins.