Hello World
\"}\nHello World
\");\n ```\n\n #### `renderHTML()` Utility\n\n Standalone utility for rendering outside of components.\n\n ```tsx\n import { renderHTML } from \"react-intlayer/html\";\n\n const jsx = renderHTML(\"Hello
\", { components: { p: 'div' } });\n ```\n\nHello World
\")}\n ```\n\n #### `renderHTML()` Utility\n\n ```svelte\n \n\n {@html renderHTML(\"Hello World
\")}\n ```\n\nHello World
\"}\nHello World
\")}Hello World
\")}Hello World
\"}\nHello World
\")}Hello World
\")}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.03/24/2026
- "move import from `{{framework}}-intlayer` to `{{framework}}-intlayer/html`"v8.5.03/24/2026
- "Add HTMLRenderer / useHTMLRenderer / renderHTML utility"v8.0.01/22/2026
- "Add HTML parsing support"v8.0.01/20/2026
If 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
import { html, type Dictionary } from "intlayer";const htmlDictionary = { key: "app", contentAutoTransformation: true, // can be set in config file content: { myHtmlContent: html("<p>Hello <strong>World</strong></p>"), },} satisfies Dictionary;export default htmlDictionary;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
import { html } from "intlayer";const myContent = html( "<MyCustomComponent title='Hello'>World</MyCustomComponent>", { MyCustomComponent: { title: "string", children: "node", }, });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 specialized 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
import { useIntlayer } from "react-intlayer";const AppContent = () => { const { myHtmlContent } = useIntlayer("app"); return <div>{myHtmlContent}</div>;};Use the .use() method to provide custom components or override tags:
Copy the code to the clipboard
{myHtmlContent.use({ p: (props) => <p className="prose" {...props} />, CustomLink: ({ children }) => <a href="/details">{children}</a>,})}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
import { HTMLProvider } from "react-intlayer/html";export const AppProvider = ({ children }) => ( <HTMLProvider components={{ p: (props) => <p className="prose" {...props} />, CustomLink: ({ children }) => <a href="/details">{children}</a>, }} > {children} </HTMLProvider>);You can also use your own HTML renderer:
Copy the code to the clipboard
import { HTMLProvider } from "react-intlayer/html";export const AppProvider = ({ children }) => ( <HTMLProvider renderHTML={async (html) => { const { renderHTML } = await import('react-intlayer/html'); return renderHTML(html); }} > {children} </HTMLProvider>);Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
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
import { HTMLRenderer } from "react-intlayer/html";<HTMLRenderer components={{ p: MyCustomP }}> {"<p>Hello World</p>"}</HTMLRenderer>useHTMLRenderer() Hook
Get a pre-configured renderer function.
Copy the code to the clipboard
import { useHTMLRenderer } from "react-intlayer/html";const renderHTML = useHTMLRenderer({ components: { strong: (props) => <strong {...props} className="text-red-500" /> }});return renderHTML("<p>Hello <strong>World</strong></p>");renderHTML() Utility
Standalone utility for rendering outside of components.
Copy the code to the clipboard
import { renderHTML } from "react-intlayer/html";const jsx = renderHTML("<p>Hello</p>", { components: { p: 'div' } });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 (Only for Vue/Svelte 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.