Skip to content

Vite Plugin

API reference for @inlinecms/vite-plugin.

The Vite plugin transforms JSX at build time — replacing inline-cms annotated elements with InlineCMS wrapper components and injecting stable fingerprint keys.

vite.config.ts
import { inlineCMS } from '@inlinecms/vite-plugin'
export default defineConfig({
plugins: [
inlineCMS({
apiKey: 'your-key',
apiUrl: 'https://cms.yourdomain.com',
cdnUrl: 'https://cdn.yourdomain.com',
}),
react(), // or vue()
],
})
OptionTypeRequiredDescription
apiKeystringYesProject API key, injected as VITE_INLINECMS_API_KEY
apiUrlstringNoAPI URL, injected as VITE_INLINECMS_API_URL
cdnUrlstringNoCDN URL, injected as VITE_INLINECMS_CDN_URL
includeRegExpNoFile patterns to transform (default: /\.(tsx|jsx)$/)
excludeRegExpNoFile patterns to skip (default: /node_modules/)
bakeboolean | objectNoBuild-time hydration. Embed the published snapshot in the output (default: false)

When true (or an options object), a production vite build pulls the project’s published snapshot and folds it into the emitted HTML so a visitor’s first paint is published content with no API round-trip. The dev server never bakes. See the Build-Time Hydration guide for the full picture.

inlineCMS({
apiKey: 'your-key',
bake: true,
// or, with options:
// bake: { metadataFile: 'inlinecms-build.json', timeout: 10000 },
})
Sub-optionTypeDefaultDescription
enabledbooleantrueMaster switch (passing true is shorthand for {})
metadataFilestringinlinecms-build.jsonBuild-report filename, relative to the output root
timeoutnumber10000Snapshot-fetch timeout in milliseconds

Baking is fail-safe: a fetch error, a local INLINECMS_BAKE=off, or the server kill-switch all ship a working no-bake build (it can never fail your build). A <script id="inlinecms-snapshot"> is injected before your app bundle and an inlinecms-build.json report is emitted alongside the output.

// Before
<h1 inline-cms>Welcome</h1>
// After
<InlineH1 inline-cms-fingerprint="a1b2c3d4e5f6">Welcome</InlineH1>

Each element gets a stable SHA1 fingerprint derived from file:line:col. This key survives text changes — only moving the element to a different file/line changes it.

The plugin automatically adds the import for any InlineCMS component used:

import { InlineH1, InlineP } from '@inlinecms/react'

If an import from @inlinecms/react already exists, missing components are added to it.

The inline-cms boolean prop is removed after processing. It’s a build-time signal, not a runtime value.

HTML tagInlineCMS component
h1-h6InlineH1-InlineH6
pInlineP
spanInlineSpan
divInlineDiv
sectionInlineSection
articleInlineArticle
asideInlineAside
mainInlineMain
imgInlineImg
videoInlineVideo
aInlineA
blockquoteInlineBlockquote
figcaptionInlineFigcaption
figureInlineFigure
liInlineLi
labelInlineLabel

Files that don’t contain the string inline-cms are skipped entirely — zero overhead for unannotated files.

Was this page helpful? Your feedback goes straight to the docs team.