aymericzip/intlayer-skills / skills/intlayer-content
intlayer-content
VerifiedDefine rich content structures using Intlayer content nodes. Use when the user asks to "create translations", "handle pluralization", "use markdown in content", or implement "conditional content".
| File | Kind | Size |
|---|---|---|
| LICENCE.md | markdown | 10.7 KB |
| SKILL.md | skill md | 12.0 KB |
| references/concept_content.md | markdown | 35.4 KB |
| references/concept_content_condition.md | markdown | 7.7 KB |
| references/concept_content_enumeration.md | markdown | 13.6 KB |
| references/concept_content_file.md | markdown | 8.4 KB |
| references/concept_content_function-fetching.md | markdown | 4.6 KB |
| references/concept_content_gender.md | markdown | 7.9 KB |
| references/concept_content_html.md | markdown | 22.7 KB |
| references/concept_content_insertion.md | markdown | 4.7 KB |
| references/concept_content_markdown.md | markdown | 47.2 KB |
| references/concept_content_nesting.md | markdown | 8.7 KB |
| references/concept_content_plural.md | markdown | 11.3 KB |
| references/concept_content_select.md | markdown | 10.6 KB |
| references/concept_content_translation.md | markdown | 6.1 KB |
| references/concept_per-locale-file.md | markdown | 7.6 KB |
| references/packages_intlayer_exports.md | markdown | 12.4 KB |
references/concept_content_html.md
View on GitHub---
createdAt: 2026-01-20
updatedAt: 2026-09-27
priority: 8
title: "HTML Content with Custom Components"
description: "Declare HTML content in Intlayer and replace tags with your own components at render time, for rich translated text without dangerouslySetInnerHTML."
keywords:
- HTML
- Custom Components
- Rich Content
- Intlayer
- Next.js
- JavaScript
- React
- Vue
- Svelte
- Remix
- Astro
slugs:
- doc
- concept
- content
- html
history:
- version: 8.5.0
date: 2026-03-24
changes: "Add `intlayerHTML` plugin object; use `app.use(intlayerHTML)` instead of `app.use(installIntlayerHTML)`"
- version: 8.5.0
date: 2026-03-24
changes: "move import from `{{framework}}-intlayer` to `{{framework}}-intlayer/html`"
- version: 8.0.0
date: 2026-01-22
changes: "Add HTMLRenderer / useHTMLRenderer / renderHTML utility"
- version: 8.0.0
date: 2026-01-20
changes: "Add HTML parsing support"
author: aymericzip
---
# 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.
<Tabs>
<Tab label="Manual Wrapping" value="manual-wrapping">
Use the `html` function to explicitly declare HTML content. This ensures standard tags are mapped correctly even if automatic detection is disabled.
```typescript fileName="htmlDictionary.content.ts"
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;
```
</Tab>
<Tab label="Automatic Detection" value="automatic-detection">
If the string contains common HTML tags (e.g., `<p>`, `<div>`, `<strong>`, etc.), Intlayer will automatically transform it.
```typescript fileName="htmlDictionary.content.ts"
export default {
key: "app",
contentAutoTransformation: true, // can be set in config file
content: {
myHtmlContent: "<p>Hello <strong>World</strong></p>",
},
};
```
</Tab>
<Tab label="External Files" value="external-files">
Import HTML content from files. Note that currently `file()` function returns a string, which will be auto-detected as HTML if it contains tags.
```typescript fileName="htmlDictionary.content.ts"
import { html, file, t } from "intlayer";
export default {
key: "app",
content: {
content: t({
en: html(file("./content.en.html")),
fr: html(file("./content.fr.html")),
}),
},
};
```
</Tab>
</Tabs>
### 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.
```typescript
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.
<Tabs group="framework">
<Tab label="React / Next.js" value="react">
HTML nodes can be rendered directly as JSX. Standard tags work automatically.
```tsx fileName="App.tsx"
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:
```tsx
{myHtmlContent.use({
p: (props) => <p className="prose" {...props} />,
CustomLink: ({ children }) => <a href="/details">{children}</a>,
})}
```
</Tab>
<Tab label="Vue" value="vue">
In Vue, HTML content can be rendered using the `component` built-in.
```vue fileName="App.vue"
<script setup>
import { useIntlayer } from "vue-intlayer";
const { myHtmlContent } = useIntlayer("app");
</script>
<template>
<component :is="myHtmlContent" />
</template>
```
Use `.use()` for overrides:
```vue
<component :is="myHtmlContent.use({ h1: 'h2' })" />
```
</Tab>
<Tab label="Svelte" value="svelte">
Svelte renders HTML nodes as strings. Use `{@html}` to render it.
```svelte
<script lang="ts">
import { useIntlayer } from "svelte-intlayer";
const content = useIntlayer("app");
</script>
{@html $content.myHtmlContent}
```
</Tab>
<Tab label="Preact" value="preact">
Preact supports HTML nodes directly in the JSX.
```tsx fileName="App.tsx"
import { useIntlayer } from "preact-intlayer";
const AppContent = () => {
const { myHtmlContent } = useIntlayer("app");
return <div>{myHtmlContent}</div>;
};
```
</Tab>
<Tab label="Solid" value="solid">
Solid supports HTML nodes directly in the JSX.
```tsx fileName="App.tsx"
import { useIntlayer } from "solid-intlayer";
const AppContent = () => {
const { myHtmlContent } = useIntlayer("app");
return <div>{myHtmlContent}</div>;
};
```
</Tab>
<Tab label="Angular" value="angular">
Angular uses the `[innerHTML]` directive to render HTML content.
```typescript fileName="app.component.ts"
import { Component } from "@angular/core";
import { useIntlayer } from "angular-intlayer";
@Component({
selector: "app-root",
template: `<div [innerHTML]="content().myHtmlContent"></div>`,
})
export class AppComponent {
content = useIntlayer("app");
}
```
Use the `.use()` method to provide custom components or override tags:
```typescript
content().myHtmlContent.use({
p: { class: "prose" },
CustomLink: { href: "/details" },
})
```
</Tab>
<Tab label="Remix" value="remix">
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.
```tsx fileName="src/views/home.tsx"
import { useIntlayer } from "remix-intlayer";
export const HomePage = () => () => {
const { myHtmlContent } = useIntlayer("app");
return <div innerHTML={myHtmlContent.value} />;
};
```
```ts fileName="src/views/home.ts"
import { html } from "remix/html-template";
import { useIntlayer } from "remix-intlayer";
export const renderHomePage = () => {
const { myHtmlContent } = useIntlayer("app");
return html.raw`<div>${myHtmlContent.value}</div>`;
};
```
> Remix escapes interpolated values by default. `innerHTML` and `html.raw` are 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:
```tsx
<div
innerHTML={myHtmlContent.use({
p: ({ children }) => `<p class="prose">${children}</p>`,
CustomLink: ({ children }) => `<a href="/details">${children}</a>`,
})}
/>
```
</Tab>
<Tab label="Astro" value="astro">
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>`.
```astro fileName="src/pages/index.astro"
---
import { useIntlayer } from "astro-intlayer";
const { myHtmlContent } = useIntlayer("app");
---
<div set:html={myHtmlContent.value} />
```
```astro fileName="src/components/Content.astro"
<div id="content"></div>
<script>
import { useIntlayer } from "astro-intlayer";
const { myHtmlContent } = useIntlayer("app");
document.querySelector("#content")!.innerHTML = myHtmlContent.value;
</script>
```
> Astro escapes `{expressions}` by default. `set:html` is 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:
```astro
<div
set:html={myHtmlContent.use({
p: ({ children }) => `<p class="prose">${children}</p>`,
CustomLink: ({ children }) => `<a href="/details">${children}</a>`,
})}
/>
```
</Tab>
</Tabs>
## 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.
<Tabs group="framework">
<Tab label="React / Next.js" value="react">
```tsx fileName="AppProvider.tsx"
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:
```tsx fileName="AppProvider.tsx"
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.
</Tab>
<Tab label="Vue" value="vue">
```typescript fileName="main.ts"
import { createApp, h } from "vue";
import { intlayer } from "vue-intlayer";
import { intlayerHTML } from "vue-intlayer/html";
import App from "./App.vue";
const app = createApp(App);
app.use(intlayer);
app.use(intlayerHTML, {
components: {
p: (props, { slots }) => h("p", { class: "prose", ...props }, slots.default?.()),
CustomLink: (props, { slots }) => h("a", { href: "/details", ...props }, slots.default?.()),
},
});
app.mount("#app");
```
You can also use your own HTML renderer:
```typescript fileName="main.ts"
import { createApp, h } from "vue";
import { intlayer } from "vue-intlayer";
import { intlayerHTML } from "vue-intlayer/html";
import App from "./App.vue";
const app = createApp(App);
app.use(intlayer);
app.use(intlayerHTML, {
renderHTML: async (html) => {
const { renderHTML } = await import('vue-intlayer/html');
return renderHTML(html);
},
});
app.mount("#app");
```
> Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
</Tab>
<Tab label="Svelte" value="svelte">
```svelte fileName="App.svelte"
<script lang="ts">
import { HTMLProvider } from "svelte-intlayer/html";
import MyCustomP from "./MyCustomP.svelte";
</script>
<HTMLProvider
components={{
p: MyCustomP,
}}
>
<slot />
</HTMLProvider>
```
You can also use your own HTML renderer:
```svelte fileName="App.svelte"
<script lang="ts">
import { HTMLProvider } from "svelte-intlayer/html";
</script>
<HTMLProvider
renderHTML={async (html) => {
const { renderHTML } = await import('svelte-intlayer/html');
return renderHTML(html);
}}
>
<slot />
</HTMLProvider>
```
> Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
</Tab>
<Tab label="Preact" value="preact">
```tsx fileName="AppProvider.tsx"
import { HTMLProvider } from "preact-intlayer/html";
export const AppProvider = ({ children }) => (
<HTMLProvider
components={{
p: (props) => <p className="prose" {...props} />,
}}
>
{children}
</HTMLProvider>
);
```
You can also use your own HTML renderer:
```tsx fileName="AppProvider.tsx"
import { HTMLProvider } from "preact-intlayer/html";
export const AppProvider = ({ children }) => (
<HTMLProvider
renderHTML={async (html) => {
const { renderHTML } = await import('preact-intlayer/html');
return renderHTML(html);
}}
>
{children}
</HTMLProvider>
);
```
> Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
</Tab>
<Tab label="Solid" value="solid">
```tsx fileName="AppProvider.tsx"
import { HTMLProvider } from "solid-intlayer/html";
export const AppProvider = (props) => (
<HTMLProvider
components={{
p: (props) => <p className="prose" {...props} />,
}}
>
{props.children}
</HTMLProvider>
);
```
You can also use your own HTML renderer:
```tsx fileName="AppProvider.tsx"
import { HTMLProvider } from "solid-intlayer/html";
export const AppProvider = (props) => (
<HTMLProvider
renderHTML={async (html) => {
const { renderHTML } = await import('solid-intlayer/html');
return renderHTML(html);
}}
>
{props.children}
</HTMLProvider>
);
```
> Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
</Tab>
<Tab label="Angular" value="angular">
```typescript fileName="app.config.ts"
import { createIntlayerHTMLProvider } from "angular-intlayer/html";
export const appConfig: ApplicationConfig = {
providers: [
createIntlayerHTMLProvider({
components: {
p: { class: "prose" },
CustomLink: { href: "/details" },
},
}),
],
};
```
You can also use your own HTML renderer:
```typescript fileName="app.config.ts"
import { createIntlayerHTMLProvider } from "angular-intlayer/html";
export const appConfig: ApplicationConfig = {
providers: [
createIntlayerHTMLProvider({
renderHTML: async (html) => {
const { renderHTML } = await import('angular-intlayer/html');
return renderHTML(html);
},
}),
],
};
```
> Importing your HTML renderer dynamically is a good way to reduce the bundle size of your application.
</Tab>
<Tab label="Remix" value="remix">
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()`.
```typescript fileName="src/router.ts"
import { installIntlayerHTML } from "remix-intlayer/html";
installIntlayerHTML({
renderHTML: (html) => html.replaceAll("<p>", '<p class="prose">'),
});
```
> Use `installIntlayerHTMLDynamic(async () => …)` to load the renderer itself lazily; the loader runs on the first call only.
</Tab>
<Tab label="Astro" value="astro">
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()`.
```typescript fileName="src/middleware.ts"
import { installIntlayerHTML } from "astro-intlayer/html";
import { defineMiddleware } from "astro:middleware";
// Runs once when the server starts; the Intlayer middleware itself is
// registered by the integration, ahead of this file.
installIntlayerHTML({
renderHTML: (html) => html.replaceAll("<p>", '<p class="prose">'),
});
export const onRequest = defineMiddleware((_context, next) => next());
```
> Use `installIntlayerHTMLDynamic(async () => …)` to load the renderer itself lazily; the loader runs on the first call only.
</Tab>
</Tabs>
### Manual Rendering & Advanced Tools
If you need to render raw HTML strings or have more control over the component mapping, use the following tools.
<Tabs group="framework">
<Tab label="React / Next.js" value="react">
#### `<HTMLRenderer />` Component
Render an HTML string with specific components.
```tsx
import { HTMLRenderer } from "react-intlayer/html";
<HTMLRenderer components={{ p: MyCustomP }}>
{"<p>Hello World</p>"}
</HTMLRenderer>
```
#### `useHTMLRenderer()` Hook
Get a pre-configured renderer function.
```tsx
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.
```tsx
import { renderHTML } from "react-intlayer/html";
const jsx = renderHTML("<p>Hello</p>", { components: { p: 'div' } });
```
</Tab>
<Tab label="Vue" value="vue">
#### `<HTMLRenderer />` Component
```vue
<script setup>
import { HTMLRenderer } from "vue-intlayer/html";
</script>
<template>
<HTMLRenderer content="<p>Hello World</p>" />
</template>
```
</Tab>
<Tab label="Svelte" value="svelte">
#### `<HTMLRenderer />` Component
```svelte
<script lang="ts">
import { HTMLRenderer } from "svelte-intlayer/html";
</script>
<HTMLRenderer value="<p>Hello World</p>" />
```
#### `useHTMLRenderer()` Hook
```svelte
<script lang="ts">
import { useHTMLRenderer } from "svelte-intlayer/html";
const render = useHTMLRenderer();
</script>
{@html render("<p>Hello World</p>")}
```
#### `renderHTML()` Utility
```svelte
<script lang="ts">
import { renderHTML } from "svelte-intlayer/html";
</script>
{@html renderHTML("<p>Hello World</p>")}
```
</Tab>
<Tab label="Preact" value="preact">
#### `<HTMLRenderer />` Component
```tsx
import { HTMLRenderer } from "preact-intlayer/html";
<HTMLRenderer>
{"<p>Hello World</p>"}
</HTMLRenderer>
```
#### `useHTMLRenderer()` Hook
```tsx
import { useHTMLRenderer } from "preact-intlayer/html";
const render = useHTMLRenderer();
return <div>{render("<p>Hello World</p>")}</div>;
```
#### `renderHTML()` Utility
```tsx
import { renderHTML } from "preact-intlayer/html";
return <div>{renderHTML("<p>Hello World</p>")}</div>;
```
</Tab>
<Tab label="Solid" value="solid">
#### `<HTMLRenderer />` Component
```tsx
import { HTMLRenderer } from "solid-intlayer/html";
<HTMLRenderer>
{"<p>Hello World</p>"}
</HTMLRenderer>
```
#### `useHTMLRenderer()` Hook
```tsx
import { useHTMLRenderer } from "solid-intlayer/html";
const render = useHTMLRenderer();
return <div>{render("<p>Hello World</p>")}</div>;
```
#### `renderHTML()` Utility
```tsx
import { renderHTML } from "solid-intlayer/html";
return <div>{renderHTML("<p>Hello World</p>")}</div>;
```
</Tab>
<Tab label="Angular" value="angular">
#### `IntlayerHTMLService` Service
Render an HTML string using the service.
```typescript
import { IntlayerHTMLService } from "angular-intlayer/html";
export class MyComponent {
constructor(private markdownService: IntlayerHTMLService) {}
renderHTML(html: string) {
return this.markdownService.renderHTML(html);
}
}
```
</Tab>
<Tab label="Remix" value="remix">
#### `useHTMLRenderer()` Hook
Get a renderer function pre-configured by `installIntlayerHTML()`. It returns an HTML string.
```tsx
import { useHTMLRenderer } from "remix-intlayer/html";
const renderHTML = useHTMLRenderer();
return <div innerHTML={renderHTML("<p>Hello <strong>World</strong></p>")} />;
```
#### `renderHTML()` Utility
Standalone utility that ignores the global configuration.
```tsx
import { renderHTML } from "remix-intlayer/html";
const html = renderHTML("<p>Hello</p>");
```
</Tab>
<Tab label="Astro" value="astro">
#### `useHTMLRenderer()` Hook
Get a renderer function pre-configured by `installIntlayerHTML()`. It returns an HTML string.
```astro
---
import { useHTMLRenderer } from "astro-intlayer/html";
const renderHTML = useHTMLRenderer();
---
<div set:html={renderHTML("<p>Hello <strong>World</strong></p>")} />
```
#### `renderHTML()` Utility
Standalone utility that ignores the global configuration.
```astro
---
import { renderHTML } from "astro-intlayer/html";
const html = renderHTML("<p>Hello</p>");
---
<div set:html={html} />
```
</Tab>
</Tabs>
## Options Reference
These options can be passed to `HTMLProvider`, `HTMLRenderer`, `useHTMLRenderer`, and `renderHTML`.
| 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.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |