---
createdAt: 2026-01-20
updatedAt: 2026-01-20
title: HTML Content
description: Learn how to declare and use HTML content with custom components in Intlayer. Follow this documentation to embed rich HTML-like content with dynamic component replacement in your internationalized project.
keywords:
- HTML
- Custom Components
- Rich Content
- Intlayer
- Next.js
- JavaScript
- React
- Vue
- Svelte
slugs:
- doc
- concept
- content
- html
history:
- version: 8.0.0
date: 2026-01-20
changes: Add HTML parsing support
---
# HTML Content / HTML in Intlayer
## How HTML Works
In Intlayer, HTML content is achieved through the `html` function, which parses an HTML-like string and allows you to replace tags with custom components at runtime. This approach enables you to embed rich, structured content within your dictionaries while maintaining full control over how each element is rendered.
When integrated with React Intlayer, Vue Intlayer, or Next Intlayer, standard HTML tags (such as `div`, `span`, `p`, `a`, etc.) are automatically provided by default. For custom components, you simply pass them when rendering the content.
## Setting Up HTML Content
To set up HTML content in your Intlayer project, create a content module that utilizes the `html` function. Below are examples in various formats.
```typescript fileName="**/*.content.ts" contentDeclarationFormat="typescript"
import { html, t, type Dictionary } from "intlayer";
const htmlDictionary = {
key: "app",
content: {
// Simple HTML with standard tags
richText: html(
"
This is bold and italic text
"
),
// HTML with custom component
customContent: html(
"Click here to learn more about Intlayer"
),
// Multilingual HTML content
multilingualContent: t({
en: html("Hello World!
"),
fr: html("Bonjour le monde !
"),
es: html("¡Hola Mundo!
"),
}),
},
} satisfies Dictionary;
export default htmlDictionary;
```
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
import { html, t } from "intlayer";
/** @type {import('intlayer').Dictionary} */
const htmlDictionary = {
key: "app",
content: {
richText: html(
"This is bold and italic text
"
),
customContent: html(
"Click here to learn more about Intlayer"
),
multilingualContent: t({
en: html("Hello World!
"),
fr: html("Bonjour le monde !
"),
es: html("¡Hola Mundo!
"),
}),
},
};
export default htmlDictionary;
```
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
const { html, t } = require("intlayer");
/** @type {import('intlayer').Dictionary} */
const htmlDictionary = {
key: "app",
content: {
richText: html(
"This is bold and italic text
"
),
customContent: html(
"Click here to learn more about Intlayer"
),
multilingualContent: t({
en: html("Hello World!
"),
fr: html("Bonjour le monde !
"),
es: html("¡Hola Mundo!
"),
}),
},
};
module.exports = htmlDictionary;
```
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
{
"$schema": "https://intlayer.org/schema.json",
"key": "app",
"content": {
"richText": {
"nodeType": "html",
"html": "This is bold and italic text
",
},
"customContent": {
"nodeType": "html",
"html": "Click here to learn more about Intlayer",
},
},
}
```
> Standard HTML tags like `p`, `strong`, `em`, `div`, `span`, `a`, `h1`-`h6`, `ul`, `ol`, `li`, `table`, `img`, etc. are automatically available. You only need to provide custom components.
## Using HTML Content with React Intlayer
To utilize HTML content within a React component, import and use the `useIntlayer` hook from the `react-intlayer` package. HTML content can be rendered directly as a node, or you can use the `.use()` method to provide custom components or override default tags.
```tsx fileName="**/*.tsx" codeFormat="typescript"
import type { FC } from "react";
import { useIntlayer, HTMLProvider } from "react-intlayer";
const HTMLComponent: FC = () => {
const { richText, customContent, multilingualContent } = useIntlayer("app");
return (
{/* Standard HTML tags work automatically */}
{richText}
{/* Overriding default tags using .use() */}
{richText.use({
p: (props) => (
),
})}
{/* With custom components using .use() */}
{customContent.use({
CustomLink: ({ children }) => (
{children}
),
})}
{/* Using HTMLProvider to define components globally */}
(
),
CustomLink: ({ children }) => (
{children}
),
}}
>
{/* All HTML content inside will use the globally defined components */}
{richText}
{customContent}
{/* Multilingual content works the same way */}
{multilingualContent}
);
};
export default HTMLComponent;
```
```jsx fileName="**/*.mjx" codeFormat="esm"
import { useIntlayer, HTMLProvider } from "react-intlayer";
const HTMLComponent = () => {
const { richText, customContent, multilingualContent } = useIntlayer("app");
return (
{/* Standard HTML tags work automatically - can use directly */}
{richText}
{/* Or call it explicitly */}
{richText()}
{/* With custom component overrides */}
{richText({
p: (props) => (
),
})}
{/* With custom component */}
{customContent({
CustomLink: ({ children }) => (
{children}
),
})}
{/* Using HTMLProvider to define components globally */}
(
{children}
),
}}
>
{customContent}
{/* Multilingual content works the same way */}
{multilingualContent}
);
};
export default HTMLComponent;
```
```jsx fileName="**/*.cjs" codeFormat="commonjs"
const { useIntlayer, HTMLProvider } = require("react-intlayer");
const HTMLComponent = () => {
const { richText, customContent, multilingualContent } = useIntlayer("app");
return (
{/* Standard HTML tags work automatically - can use directly */}
{richText}
{/* Or call it explicitly */}
{richText()}
{/* With custom component */}
{customContent({
CustomLink: ({ children }) => (
{children}
),
})}
{/* Using HTMLProvider to define components globally */}
(
{children}
),
}}
>
{customContent}
{/* Multilingual content works the same way */}
{multilingualContent}
);
};
module.exports = HTMLComponent;
```
## Using HTML Content with Vue Intlayer
In Vue, HTML content works similarly. The content node can be rendered directly using the `` syntax, or you can use the `.use()` method to provide custom components.
### Basic Usage
```vue fileName="**/*.vue"
```
### Using the Global Provider
Vue Intlayer provides `installIntlayerHTML` to define components globally, similar to `installIntlayerMarkdown`. This is useful when you want to use the same custom components across your entire application.
```typescript fileName="main.ts"
import { createApp } from "vue";
import { installIntlayer, installIntlayerHTML } from "vue-intlayer";
import App from "./App.vue";
const app = createApp(App);
// Install Intlayer
installIntlayer(app);
// Install HTML provider with global components
installIntlayerHTML(app, {
components: {
// Override default tags globally
p: (props, { slots }) =>
h("p", { class: "prose", ...props }, slots.default?.()),
a: (props, { slots }) =>
h(
"a",
{ class: "text-blue-500 hover:underline", ...props },
slots.default?.()
),
// Define custom components globally
CustomLink: (props, { slots }) =>
h(
"a",
{ href: "/learn-more", class: "custom-link", ...props },
slots.default?.()
),
CustomButton: (props, { slots }) =>
h("button", { class: "btn btn-primary", ...props }, slots.default?.()),
},
});
app.mount("#app");
```
Once configured, all HTML content will automatically use these components:
```vue fileName="**/*.vue"
```
### Using Custom Render Function
You can also provide a completely custom render function:
```typescript fileName="main.ts"
import { createApp, h } from "vue";
import { installIntlayer, installIntlayerHTML } from "vue-intlayer";
import App from "./App.vue";
const app = createApp(App);
installIntlayer(app);
// Provide a custom render function
installIntlayerHTML(app, (htmlString, components) => {
// Your custom HTML rendering logic
// Return VNode or VNode[]
});
app.mount("#app");
```
## Using HTML Content with Svelte Intlayer
In Svelte, HTML content can be used with the `useIntlayer` function. The content node can be rendered directly using the `{@html ...}` syntax, or you can use the `.use()` method to provide custom components.
### Basic Usage
```svelte fileName="**/*.svelte"
{@html richText}
{@html customContent.use({ CustomLink })}
```
### Using the Global Provider with Context
Svelte Intlayer provides a context-based approach to define components globally using `setHTMLContext`.
```svelte fileName="App.svelte"
```
Then in child components:
```svelte fileName="**/*.svelte"
{@html richText(components)}
{@html customContent(components)}
{@html customContent({
...components,
CustomLink: ({ children }) => {
const el = document.createElement("a");
el.href = "/other-link";
// ...
return el;
},
})}
```
### Using with Svelte Components
For more complex cases, you can use Svelte components as custom elements:
```svelte fileName="CustomLink.svelte"
```
```svelte fileName="Page.svelte"
{@html customContent({
CustomLink: createSvelteComponent(CustomLink),
})}
```
## Using HTML Content with Next Intlayer
With the `next-intlayer` package, HTML content works the same way as with React Intlayer. You can use `richText` directly or call it as `richText()`.
```tsx fileName="**/*.tsx" codeFormat="typescript"
"use client";
import { useIntlayer, HTMLProvider } from "next-intlayer";
export const HTMLComponent = () => {
const { richText, customContent } = useIntlayer("app");
return (
{/* Standard HTML tags work automatically - can use directly */}
{richText}
{/* Or call it explicitly */}
{richText()}
{/* With custom component */}
{customContent({
CustomLink: ({ children }) => (
{children}
),
})}
{/* Using HTMLProvider for global components */}
(
{children}
),
}}
>
{customContent}
);
};
```
## Advanced Usage
### Overriding Default HTML Tags
You can override the default rendering of standard HTML tags by passing them as custom components:
```tsx fileName="**/*.tsx" codeFormat="typescript"
import type { FC } from "react";
import { useIntlayer } from "react-intlayer";
const StyledHTMLComponent: FC = () => {
const { richText } = useIntlayer("app");
return (
{richText({
// Override the default 'strong' tag with custom styling
strong: ({ children }) => (
{children}
),
// Override 'em' with custom styling
em: ({ children }) => (
{children}
),
})}
);
};
export default StyledHTMLComponent;
```
### Tag Attributes
You can use attributes on your tags. The HTML parser will extract them and pass them to your components:
```typescript fileName="**/*.content.ts" contentDeclarationFormat="typescript"
import { html, type Dictionary } from "intlayer";
const htmlWithAttributes = {
key: "html-attributes",
content: {
linkedContent: html(
'Visit our website for more info'
),
imageContent: html(
'
'
),
},
} satisfies Dictionary;
export default htmlWithAttributes;
```
### Self-Closing Tags
Self-closing tags are supported:
```typescript fileName="**/*.content.ts" contentDeclarationFormat="typescript"
import { html, type Dictionary } from "intlayer";
const selfClosingTags = {
key: "self-closing",
content: {
breakLine: html("First line
Second line"),
image: html('
'),
horizontalRule: html("Above
Below
"),
},
} satisfies Dictionary;
export default selfClosingTags;
```
## Supported HTML Tags
The following standard HTML tags are automatically supported:
- **Document structure**: `html`, `head`, `body`, `main`, `header`, `footer`, `nav`, `aside`, `article`, `section`, `div`, `span`
- **Headings**: `h1`, `h2`, `h3`, `h4`, `h5`, `h6`
- **Text content**: `p`, `a`, `strong`, `b`, `em`, `i`, `u`, `s`, `del`, `ins`, `mark`, `small`, `sub`, `sup`, `code`, `pre`, `blockquote`, `q`, `cite`, `abbr`, `address`, `time`, `kbd`, `samp`, `var`
- **Lists**: `ul`, `ol`, `li`, `dl`, `dt`, `dd`
- **Tables**: `table`, `thead`, `tbody`, `tfoot`, `tr`, `th`, `td`, `caption`, `colgroup`, `col`
- **Forms**: `form`, `input`, `textarea`, `button`, `select`, `option`, `optgroup`, `label`, `fieldset`, `legend`, `datalist`, `output`, `progress`, `meter`
- **Media**: `img`, `video`, `audio`, `source`, `track`, `picture`, `figure`, `figcaption`, `iframe`, `embed`, `object`, `canvas`, `svg`
- **Interactive**: `details`, `summary`, `dialog`
- **Other**: `br`, `hr`, `wbr`, `ruby`, `rt`, `rp`, `bdi`, `bdo`, `data`, `template`, `slot`
## Additional Resources
For more detailed information on configuration and usage, refer to the following resources:
- [Intlayer CLI Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/index.md)
- [React Intlayer Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_create_react_app.md)
- [Next Intlayer Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_nextjs_15.md)
- [Vue Intlayer Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_vite_vue.md)
- [Svelte Intlayer Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_svelte.md)
These resources provide further insights into the setup and usage of Intlayer across various environments and frameworks.