Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Add `intlayerHTML` plugin object; use `app.use(intlayerHTML)` instead of `app.use(installIntlayerHTML)`"v8.5.024/03/2026
- "move import from `{{framework}}-intlayer` to `{{framework}}-intlayer/html`"v8.5.024/03/2026
- "Add HTMLRenderer / useHTMLRenderer / renderHTML utility"v8.0.022/01/2026
- "Add HTML parsing support"v8.0.020/01/2026
The content of this page was translated using an AI.
See the last version of the original content in EnglishIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
HTML Content / HTML in Intlayer
Intlayer supports HTML content, allowing you to embed rich, structured content within your dictionaries. This content can be rendered with standard HTML tags or replaced with custom components at runtime.
Declaring HTML Content
You can declare HTML content using the html function or simply as a string.
Use the html function to explicitly declare HTML content. This ensures standard tags are mapped correctly even if automatic detection is disabled.
Copy the code to the clipboard
If the string contains common HTML tags (e.g., <p>, <div>, <strong>, etc.), Intlayer will automatically transform it.
Copy the code to the clipboard
Import HTML content from files. Note that currently file() function returns a string, which will be auto-detected as HTML if it contains tags.
Copy the code to the clipboard
The html() Node
The html() function is a new feature in Intlayer v8 that allows you to explicitly define HTML content in your dictionaries. While Intlayer can often auto-detect HTML content, using the html() function provides several advantages:
- Type Safety: The
html()function allows you to define the expected props for custom components, providing better autocompletion and type checking in your editor. - Explicit Declaration: It ensures that a string is always treated as HTML, even if it doesn't contain standard HTML tags that would trigger auto-detection.
- Custom Component Definition: You can pass a second argument to
html()to define the custom components and their expected prop types.
Copy the code to the clipboard
When using the .use() method on an HTML node, the components you provide will be checked against the definition provided in the html() function (if available).
Rendering HTML
Rendering can be handled automatically by Intlayer's content system or manually using specialised tools.
Automatic Rendering (using useIntlayer)
When you access content via useIntlayer, HTML nodes are already prepared for rendering.
HTML nodes can be rendered directly as JSX. Standard tags work automatically.
Copy the code to the clipboard
Use the .use() method to provide custom components or override tags:
Copy the code to the clipboard
In Vue, HTML content can be rendered using the component built-in.
Copy the code to the clipboard
Use .use() for overrides:
Copy the code to the clipboard
Svelte renders HTML nodes as strings. Use {@html} to render it.
Copy the code to the clipboard
Preact supports HTML nodes directly in the JSX.
Copy the code to the clipboard
Solid supports HTML nodes directly in the JSX.
Copy the code to the clipboard
Angular uses the [innerHTML] directive to render HTML content.
Copy the code to the clipboard
Use the .use() method to provide custom components or override tags:
Copy the code to the clipboard
In Remix 3, HTML nodes resolve to an HTML string. Inject it with the innerHTML prop of Remix JSX, or with html.raw in an html-template view.
Copy the code to the clipboard
Copy the code to the clipboard
Remix escapes interpolated values by default.innerHTMLandhtml.raware the two opt-outs, which is what an HTML string needs.
Use the .use() method to override tags or map custom components. Overrides are functions returning an HTML string:
Copy the code to the clipboard
In Astro, HTML nodes resolve to an HTML string. Inject it with the set:html directive in the template, or with innerHTML in a client <script>.
Copy the code to the clipboard
Copy the code to the clipboard
Astro escapes{expressions}by default.set:htmlis the opt-out, which is what an HTML string needs.
Use the .use() method to override tags or map custom components. Overrides are functions returning an HTML string:
Copy the code to the clipboard
Global Configuration with HTMLProvider
You can configure HTML rendering globally for your entire application. This is ideal for defining custom components that should be available in all HTML content.
Copy the code to the clipboard
You can also use your own HTML renderer:
Copy the code to the clipboard
Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
Copy the code to the clipboard
You can also use your own HTML renderer:
Copy the code to the clipboard
Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
Copy the code to the clipboard
You can also use your own HTML renderer:
Copy the code to the clipboard
Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
Copy the code to the clipboard
You can also use your own HTML renderer:
Copy the code to the clipboard
Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
Copy the code to the clipboard
You can also use your own HTML renderer:
Copy the code to the clipboard
Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
Copy the code to the clipboard
You can also use your own HTML renderer:
Copy the code to the clipboard
Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
Remix has no component tree to hold a provider, so the configuration is installed once, as a singleton, at server start. It configures the renderer returned by useHTMLRenderer(). The html nodes returned by useIntlayer are rendered as-is; override their tags per node with .use().
Copy the code to the clipboard
Use installIntlayerHTMLDynamic(async () => …) to load the renderer itself lazily; the loader runs on the first call only.
Astro has no component tree to hold a provider, so the configuration is installed once, as a singleton, in the middleware (server) and in a client <script> (browser). It configures the renderer returned by useHTMLRenderer(). The html nodes returned by useIntlayer are rendered as-is; override their tags per node with .use().
Copy the code to the clipboard
Use installIntlayerHTMLDynamic(async () => …) to load the renderer itself lazily; the loader runs on the first call only.
Manual Rendering & Advanced Tools
If you need to render raw HTML strings or have more control over the component mapping, use the following tools.
<HTMLRenderer /> Component
Render an HTML string with specific components.
Copy the code to the clipboard
useHTMLRenderer() Hook
Get a pre-configured renderer function.
Copy the code to the clipboard
renderHTML() Utility
Standalone utility for rendering outside of components.
Copy the code to the clipboard
<HTMLRenderer /> Component
Copy the code to the clipboard
<HTMLRenderer /> Component
Copy the code to the clipboard
useHTMLRenderer() Hook
Copy the code to the clipboard
renderHTML() Utility
Copy the code to the clipboard
<HTMLRenderer /> Component
Copy the code to the clipboard
useHTMLRenderer() Hook
Copy the code to the clipboard
renderHTML() Utility
Copy the code to the clipboard
<HTMLRenderer /> Component
Copy the code to the clipboard
useHTMLRenderer() Hook
Copy the code to the clipboard
renderHTML() Utility
Copy the code to the clipboard
IntlayerHTMLService Service
Render an HTML string using the service.
Copy the code to the clipboard
useHTMLRenderer() Hook
Get a renderer function pre-configured by installIntlayerHTML(). It returns an HTML string.
Copy the code to the clipboard
renderHTML() Utility
Standalone utility that ignores the global configuration.
Copy the code to the clipboard
useHTMLRenderer() Hook
Get a renderer function pre-configured by installIntlayerHTML(). It returns an HTML string.
Copy the code to the clipboard
renderHTML() Utility
Standalone utility that ignores the global configuration.
Copy the code to the clipboard
Options Reference
These options can be passed to HTMLProvider, HTMLRenderer, useHTMLRenderer, and renderHTML.
Open the table in a modal to view all data content clearly
| Option | Type | Default | Description |
|---|---|---|---|
components | Record<string, any> | {} | A map of HTML tags or custom component names to components. |
renderHTML | Function | null | A custom rendering function to completely replace the default HTML parser (Vue, Svelte, Remix and Astro providers). |
Note: For React and Preact, standard HTML tags are automatically provided. You only need to pass the components prop if you want to override them or add custom components.