@intlayer/docs 5.7.6 → 5.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/generated/docs.entry.cjs +44 -238
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +44 -238
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -2
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/CI_CD.md +67 -41
- package/docs/ar/intlayer_with_tanstack.md +457 -0
- package/docs/ar/packages/next-intlayer/index.md +0 -1
- package/docs/ar/packages/react-intlayer/index.md +0 -1
- package/docs/de/CI_CD.md +63 -37
- package/docs/de/intlayer_with_tanstack.md +458 -0
- package/docs/de/packages/next-intlayer/index.md +0 -1
- package/docs/de/packages/react-intlayer/index.md +0 -1
- package/docs/en/CI_CD.md +51 -27
- package/docs/en/intlayer_with_tanstack.md +452 -0
- package/docs/en/packages/next-intlayer/index.md +0 -1
- package/docs/en/packages/react-intlayer/index.md +0 -1
- package/docs/en-GB/CI_CD.md +58 -32
- package/docs/en-GB/intlayer_with_tanstack.md +457 -0
- package/docs/en-GB/packages/next-intlayer/index.md +0 -1
- package/docs/en-GB/packages/react-intlayer/index.md +0 -1
- package/docs/es/CI_CD.md +68 -42
- package/docs/es/intlayer_with_tanstack.md +435 -0
- package/docs/es/packages/next-intlayer/index.md +0 -1
- package/docs/es/packages/react-intlayer/index.md +0 -1
- package/docs/fr/intlayer_with_tanstack.md +435 -0
- package/docs/fr/packages/next-intlayer/index.md +0 -1
- package/docs/fr/packages/react-intlayer/index.md +0 -1
- package/docs/hi/CI_CD.md +69 -44
- package/docs/hi/intlayer_with_tanstack.md +438 -0
- package/docs/hi/packages/next-intlayer/index.md +0 -1
- package/docs/hi/packages/react-intlayer/index.md +0 -1
- package/docs/it/CI_CD.md +67 -41
- package/docs/it/intlayer_with_tanstack.md +457 -0
- package/docs/it/packages/next-intlayer/index.md +0 -1
- package/docs/it/packages/react-intlayer/index.md +0 -1
- package/docs/ja/CI_CD.md +67 -41
- package/docs/ja/intlayer_with_tanstack.md +457 -0
- package/docs/ja/packages/next-intlayer/index.md +0 -1
- package/docs/ja/packages/react-intlayer/index.md +0 -1
- package/docs/ko/CI_CD.md +63 -37
- package/docs/ko/intlayer_with_tanstack.md +457 -0
- package/docs/ko/packages/next-intlayer/index.md +0 -1
- package/docs/ko/packages/react-intlayer/index.md +0 -1
- package/docs/pt/CI_CD.md +67 -41
- package/docs/pt/intlayer_with_tanstack.md +457 -0
- package/docs/pt/packages/next-intlayer/index.md +0 -1
- package/docs/pt/packages/react-intlayer/index.md +0 -1
- package/docs/ru/CI_CD.md +70 -44
- package/docs/ru/intlayer_with_tanstack.md +458 -0
- package/docs/ru/packages/next-intlayer/index.md +0 -1
- package/docs/ru/packages/react-intlayer/index.md +0 -1
- package/docs/zh/CI_CD.md +62 -36
- package/docs/zh/intlayer_with_tanstack.md +435 -0
- package/docs/zh/packages/next-intlayer/index.md +0 -1
- package/docs/zh/packages/react-intlayer/index.md +0 -1
- package/package.json +9 -9
- package/src/generated/docs.entry.ts +44 -238
- package/docs/ar/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/ar/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/de/packages/next-intlayer/useIntlayerAsync.md +0 -262
- package/docs/de/packages/react-intlayer/useIntlayerAsync.md +0 -256
- package/docs/en/packages/next-intlayer/useIntlayerAsync.md +0 -239
- package/docs/en/packages/react-intlayer/useIntlayerAsync.md +0 -254
- package/docs/en-GB/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/en-GB/packages/react-intlayer/useIntlayerAsync.md +0 -257
- package/docs/es/packages/next-intlayer/useIntlayerAsync.md +0 -240
- package/docs/es/packages/react-intlayer/useIntlayerAsync.md +0 -276
- package/docs/fr/packages/next-intlayer/useIntlayerAsync.md +0 -238
- package/docs/fr/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/hi/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/hi/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/it/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/it/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/ja/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/ja/packages/react-intlayer/useIntlayerAsync.md +0 -268
- package/docs/ko/packages/next-intlayer/useIntlayerAsync.md +0 -260
- package/docs/ko/packages/react-intlayer/useIntlayerAsync.md +0 -271
- package/docs/pt/packages/next-intlayer/useIntlayerAsync.md +0 -238
- package/docs/pt/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/ru/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/ru/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/zh/packages/next-intlayer/useIntlayerAsync.md +0 -239
- package/docs/zh/packages/react-intlayer/useIntlayerAsync.md +0 -257
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
createdAt: 2024-08-11
|
|
3
|
-
updatedAt: 2025-06-29
|
|
4
|
-
title: useIntlayerAsync Hook Dokumentation | react-intlayer
|
|
5
|
-
description: Siehe, wie der useIntlayerAsync Hook für das react-intlayer Paket verwendet wird
|
|
6
|
-
keywords:
|
|
7
|
-
- useIntlayerAsync
|
|
8
|
-
- Wörterbuch
|
|
9
|
-
- Schlüssel
|
|
10
|
-
- Intlayer
|
|
11
|
-
- Internationalisierung
|
|
12
|
-
- Dokumentation
|
|
13
|
-
- Next.js
|
|
14
|
-
- JavaScript
|
|
15
|
-
- React
|
|
16
|
-
slugs:
|
|
17
|
-
- doc
|
|
18
|
-
- packages
|
|
19
|
-
- react-intlayer
|
|
20
|
-
- useIntlayerAsync
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
# React-Integration: `useIntlayerAsync` Hook Dokumentation
|
|
24
|
-
|
|
25
|
-
Der `useIntlayerAsync` Hook erweitert die Funktionalität von `useIntlayer`, indem er nicht nur vorgerenderte Wörterbücher zurückgibt, sondern auch Updates asynchron abruft. Dadurch ist er ideal für Anwendungen, die ihren lokalisierten Inhalt nach dem ersten Rendern häufig aktualisieren.
|
|
26
|
-
|
|
27
|
-
## Überblick
|
|
28
|
-
|
|
29
|
-
- **Asynchrones Laden von Wörterbüchern:**
|
|
30
|
-
Beim ersten Mount gibt `useIntlayerAsync` zunächst ein vorab geladenes oder statisch eingebundenes lokales Wörterbuch zurück (genau wie `useIntlayer`) und lädt dann asynchron alle neu verfügbaren entfernten Wörterbücher nach und fügt sie zusammen.
|
|
31
|
-
- **Statusverwaltung des Ladevorgangs:**
|
|
32
|
-
Der Hook stellt außerdem einen `isLoading`-Status bereit, der anzeigt, wann ein entferntes Wörterbuch geladen wird. Dies ermöglicht es Entwicklern, Ladeanzeigen oder Skeleton-Zustände für eine flüssigere Benutzererfahrung anzuzeigen.
|
|
33
|
-
|
|
34
|
-
## Einrichtung der Umgebung
|
|
35
|
-
|
|
36
|
-
Intlayer bietet ein kopfloses Content Source Management (CSM)-System, das es Nicht-Entwicklern ermöglicht, Anwendungsinhalte nahtlos zu verwalten und zu aktualisieren. Durch die Verwendung des intuitiven Dashboards von Intlayer kann Ihr Team lokalisierten Text, Bilder und andere Ressourcen bearbeiten, ohne direkt den Code ändern zu müssen. Dies vereinfacht den Content-Management-Prozess, fördert die Zusammenarbeit und stellt sicher, dass Aktualisierungen schnell und einfach vorgenommen werden können.
|
|
37
|
-
|
|
38
|
-
Um mit Intlayer zu starten:
|
|
39
|
-
|
|
40
|
-
1. **Registrieren Sie sich und erhalten Sie einen Zugriffstoken** unter [https://intlayer.org/dashboard](https://intlayer.org/dashboard).
|
|
41
|
-
2. **Fügen Sie die Zugangsdaten zu Ihrer Konfigurationsdatei hinzu:**
|
|
42
|
-
Konfigurieren Sie in Ihrem React-Projekt den Intlayer-Client mit Ihren Zugangsdaten:
|
|
43
|
-
|
|
44
|
-
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
45
|
-
import type { IntlayerConfig } from "intlayer";
|
|
46
|
-
|
|
47
|
-
export default {
|
|
48
|
-
// ...
|
|
49
|
-
editor: {
|
|
50
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
51
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
52
|
-
},
|
|
53
|
-
} satisfies IntlayerConfig;
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
57
|
-
import { type IntlayerConfig } from "intlayer";
|
|
58
|
-
|
|
59
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
60
|
-
const config = {
|
|
61
|
-
// ...
|
|
62
|
-
editor: {
|
|
63
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
64
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default config;
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
72
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
73
|
-
const config = {
|
|
74
|
-
// ...
|
|
75
|
-
editor: {
|
|
76
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
77
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
module.exports = config;
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
3. **Schieben Sie ein neues Sprachwörterbuch zu Intlayer:**
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
npx intlayer dictionary push -d my-first-dictionary-key
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Dieser Befehl lädt Ihre anfänglichen Inhaltswörterbücher hoch und macht sie für asynchrones Abrufen und Bearbeiten über die Intlayer-Plattform verfügbar.
|
|
91
|
-
|
|
92
|
-
## Importieren von `useIntlayerAsync` in React
|
|
93
|
-
|
|
94
|
-
Importieren Sie in Ihren React-Komponenten `useIntlayerAsync`:
|
|
95
|
-
|
|
96
|
-
```ts codeFormat="typescript"
|
|
97
|
-
import { useIntlayerAsync } from "react-intlayer";
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
```js codeFormat="esm"
|
|
101
|
-
import { useIntlayerAsync } from "react-intlayer";
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
```js codeFormat="commonjs"
|
|
105
|
-
const { useIntlayerAsync } = require("react-intlayer");
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Parameter
|
|
109
|
-
|
|
110
|
-
1. **`key`**:
|
|
111
|
-
**Typ**: `DictionaryKeys`
|
|
112
|
-
Der Wörterbuchschlüssel, der verwendet wird, um den lokalisierten Inhaltsblock zu identifizieren. Dieser Schlüssel sollte in Ihren Inhaltsdeklarationsdateien definiert sein.
|
|
113
|
-
|
|
114
|
-
2. **`locale`** (optional):
|
|
115
|
-
**Typ**: `Locales`
|
|
116
|
-
Die spezifische Locale, auf die Sie abzielen möchten. Wenn ausgelassen, verwendet der Hook die Locale aus dem aktuellen Intlayer-Kontext.
|
|
117
|
-
|
|
118
|
-
3. **`isRenderEditor`** (optional, Standardwert `true`):
|
|
119
|
-
**Typ**: `boolean`
|
|
120
|
-
Bestimmt, ob der Inhalt für die Darstellung mit der Intlayer-Editor-Overlay bereit sein soll. Wenn auf `false` gesetzt, schließen die zurückgegebenen Wörterbuchdaten editor-spezifische Funktionen aus.
|
|
121
|
-
|
|
122
|
-
## Rückgabewert
|
|
123
|
-
|
|
124
|
-
Der Hook gibt ein Wörterbuchobjekt zurück, das lokalisierten Inhalt enthält, der durch `key` und `locale` indiziert ist. Es enthält außerdem ein `isLoading`-Boolean, das angibt, ob gerade ein entferntes Wörterbuch geladen wird.
|
|
125
|
-
|
|
126
|
-
## Beispielhafte Verwendung in einer React-Komponente
|
|
127
|
-
|
|
128
|
-
```tsx fileName="src/components/ComponentExample.tsx" codeFormat="typescript"
|
|
129
|
-
import { useEffect, type FC } from "react";
|
|
130
|
-
import { useIntlayerAsync } from "react-intlayer";
|
|
131
|
-
|
|
132
|
-
export const ComponentExample: FC = () => {
|
|
133
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
134
|
-
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
if (isLoading) {
|
|
137
|
-
console.log("Inhalt wird geladen...");
|
|
138
|
-
}
|
|
139
|
-
}, [isLoading]);
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<div>
|
|
143
|
-
{isLoading ? (
|
|
144
|
-
<div>
|
|
145
|
-
<h1>Lädt…</h1>
|
|
146
|
-
<p>Bitte warten Sie, während der Inhalt aktualisiert wird.</p>
|
|
147
|
-
</div>
|
|
148
|
-
) : (
|
|
149
|
-
<div>
|
|
150
|
-
<h1>{title.value}</h1>
|
|
151
|
-
<p>{description.value}</p>
|
|
152
|
-
</div>
|
|
153
|
-
)}
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
```jsx fileName="src/components/ComponentExample.mjx" codeFormat="esm"
|
|
160
|
-
import { useEffect } from "react";
|
|
161
|
-
import { useIntlayerAsync } from "react-intlayer";
|
|
162
|
-
|
|
163
|
-
const ComponentExample = () => {
|
|
164
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
165
|
-
|
|
166
|
-
useEffect(() => {
|
|
167
|
-
if (isLoading) {
|
|
168
|
-
console.log("Inhalt wird geladen...");
|
|
169
|
-
}
|
|
170
|
-
}, [isLoading]);
|
|
171
|
-
|
|
172
|
-
return (
|
|
173
|
-
<div>
|
|
174
|
-
{isLoading ? (
|
|
175
|
-
<div>
|
|
176
|
-
<h1>Lädt…</h1>
|
|
177
|
-
<p>Bitte warten Sie, während der Inhalt aktualisiert wird.</p>
|
|
178
|
-
</div>
|
|
179
|
-
) : (
|
|
180
|
-
<div>
|
|
181
|
-
<h1>{title.value}</h1>
|
|
182
|
-
<p>{description.value}</p>
|
|
183
|
-
</div>
|
|
184
|
-
)}
|
|
185
|
-
</div>
|
|
186
|
-
);
|
|
187
|
-
};
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
```jsx fileName="src/components/ComponentExample.csx" codeFormat="commonjs"
|
|
191
|
-
const { useEffect } = require("react");
|
|
192
|
-
const { useIntlayerAsync } = require("react-intlayer");
|
|
193
|
-
|
|
194
|
-
const ComponentExample = () => {
|
|
195
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
196
|
-
|
|
197
|
-
useEffect(() => {
|
|
198
|
-
if (isLoading) {
|
|
199
|
-
console.log("Inhalt wird geladen...");
|
|
200
|
-
}
|
|
201
|
-
}, [isLoading]);
|
|
202
|
-
|
|
203
|
-
return (
|
|
204
|
-
<div>
|
|
205
|
-
{isLoading ? (
|
|
206
|
-
<div>
|
|
207
|
-
<h1>Lädt…</h1>
|
|
208
|
-
<p>Bitte warten Sie, während der Inhalt aktualisiert wird.</p>
|
|
209
|
-
</div>
|
|
210
|
-
) : (
|
|
211
|
-
<div>
|
|
212
|
-
<h1>{title.value}</h1>
|
|
213
|
-
<p>{description.value}</p>
|
|
214
|
-
</div>
|
|
215
|
-
)}
|
|
216
|
-
</div>
|
|
217
|
-
);
|
|
218
|
-
};
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
**Wichtige Punkte:**
|
|
222
|
-
|
|
223
|
-
- Beim ersten Rendern stammen `title` und `description` aus dem vorab geladenen oder statisch eingebetteten Lokalisierungswörterbuch.
|
|
224
|
-
- Solange `isLoading` auf `true` gesetzt ist, wird im Hintergrund eine Anfrage ausgeführt, um ein aktualisiertes Wörterbuch abzurufen.
|
|
225
|
-
- Sobald der Abruf abgeschlossen ist, werden `title` und `description` mit dem neuesten Inhalt aktualisiert, und `isLoading` wird wieder auf `false` gesetzt.
|
|
226
|
-
|
|
227
|
-
## Umgang mit der Attribut-Lokalisierung
|
|
228
|
-
|
|
229
|
-
Sie können auch lokalisierte Attributwerte für verschiedene HTML-Eigenschaften abrufen (z. B. `alt`, `title`, `aria-label`):
|
|
230
|
-
|
|
231
|
-
```jsx
|
|
232
|
-
<img src={title.image.src.value} alt={title.image.alt.value} />
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
## Wörterbuchdateien
|
|
236
|
-
|
|
237
|
-
Alle Inhalts-Schlüssel müssen in Ihren Inhaltsdeklarationsdateien definiert sein, um Typensicherheit zu gewährleisten und Laufzeitfehler zu vermeiden. Diese Dateien ermöglichen die TypeScript-Validierung, sodass Sie immer auf vorhandene Schlüssel und Sprachen verweisen.
|
|
238
|
-
|
|
239
|
-
Anleitungen zum Einrichten von Inhaltsdeklarationsdateien sind [hier](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/dictionary/get_started.md) verfügbar.
|
|
240
|
-
|
|
241
|
-
## Weitere Informationen
|
|
242
|
-
|
|
243
|
-
- **Intlayer Visual Editor:**
|
|
244
|
-
Integration mit dem Intlayer Visual Editor zur Verwaltung und Bearbeitung von Inhalten direkt über die Benutzeroberfläche. Weitere Details [hier](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/intlayer_visual_editor.md).
|
|
245
|
-
|
|
246
|
-
---
|
|
247
|
-
|
|
248
|
-
**Zusammenfassung**, `useIntlayerAsync` ist ein leistungsstarker React-Hook, der entwickelt wurde, um die Benutzererfahrung zu verbessern und die Aktualität der Inhalte zu gewährleisten, indem vorgerenderte oder vorab geladene Wörterbücher mit asynchronen Wörterbuchaktualisierungen zusammengeführt werden. Durch die Nutzung von `isLoading` und TypeScript-basierten Inhaltsdeklarationen können Sie dynamische, lokalisierte Inhalte nahtlos in Ihre React-Anwendungen integrieren.
|
|
249
|
-
|
|
250
|
-
## Dokumentationsverlauf
|
|
251
|
-
|
|
252
|
-
- 5.5.10 - 2025-06-29: Historie initialisiert
|
|
253
|
-
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
```
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
createdAt: 2024-08-11
|
|
3
|
-
updatedAt: 2025-06-29
|
|
4
|
-
title: useIntlayerAsync Hook Documentation | next-intlayer
|
|
5
|
-
description: See how to use the useIntlayerAsync hook for next-intlayer package
|
|
6
|
-
keywords:
|
|
7
|
-
- useIntlayerAsync
|
|
8
|
-
- dictionary
|
|
9
|
-
- key
|
|
10
|
-
- Intlayer
|
|
11
|
-
- Internationalization
|
|
12
|
-
- Documentation
|
|
13
|
-
- Next.js
|
|
14
|
-
- JavaScript
|
|
15
|
-
- React
|
|
16
|
-
slugs:
|
|
17
|
-
- doc
|
|
18
|
-
- packages
|
|
19
|
-
- next-intlayer
|
|
20
|
-
- useIntlayerAsync
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
# Next.js Integration: `useIntlayerAsync` Hook Documentation
|
|
24
|
-
|
|
25
|
-
The `useIntlayerAsync` hook extends the functionality of `useIntlayer` by not only returning pre-rendered dictionaries but also fetching updates asynchronously, making it ideal for applications that frequently update their localized content after initial render.
|
|
26
|
-
|
|
27
|
-
## Overview
|
|
28
|
-
|
|
29
|
-
- **Asynchronous Dictionary Loading:**
|
|
30
|
-
On the client side, `useIntlayerAsync` first returns the pre-rendered locale dictionary (just like `useIntlayer`) and then asynchronously fetches and merges any newly available remote dictionaries.
|
|
31
|
-
- **Progress State Management:**
|
|
32
|
-
The hook also provides an `isLoading` state, indicating when a remote dictionary is being fetched. This allows developers to display loading indicators or skeleton states for a smoother user experience.
|
|
33
|
-
|
|
34
|
-
## Environment Setup
|
|
35
|
-
|
|
36
|
-
Intlayer provides a headless Content Source Management (CSM) system that empowers non-developers to manage and update application content seamlessly. By using Intlayer’s intuitive dashboard, your team can edit localized text, images, and other resources without directly modifying code. This streamlines the content management process, fosters collaboration, and ensures that updates can be made quickly and easily.
|
|
37
|
-
|
|
38
|
-
To get started with Intlayer, you will first need to register and obtain an access token in the [dashboard](https://intlayer.org/dashboard). Once you have your credentials, add them to your configuration file as shown below:
|
|
39
|
-
|
|
40
|
-
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
41
|
-
import type { IntlayerConfig } from "intlayer";
|
|
42
|
-
|
|
43
|
-
export default {
|
|
44
|
-
// ...
|
|
45
|
-
editor: {
|
|
46
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
47
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
48
|
-
},
|
|
49
|
-
} satisfies IntlayerConfig;
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
53
|
-
import { type IntlayerConfig } from "intlayer";
|
|
54
|
-
|
|
55
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
56
|
-
const config = {
|
|
57
|
-
// ...
|
|
58
|
-
editor: {
|
|
59
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
60
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default config;
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
68
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
69
|
-
const config = {
|
|
70
|
-
// ...
|
|
71
|
-
editor: {
|
|
72
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
73
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
module.exports = config;
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
After configuring your credentials, you can push a new locale dictionary to Intlayer by running:
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
npx intlayer dictionary push -d my-first-dictionary-key
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
This command uploads your initial content dictionaries, making them available for asynchronous fetching and editing through the Intlayer platform.
|
|
87
|
-
|
|
88
|
-
## Importing `useIntlayerAsync` in Next.js
|
|
89
|
-
|
|
90
|
-
Since `useIntlayerAsync` is intended for **client-side** components, you’ll import it from the same client entry point as `useIntlayer`:
|
|
91
|
-
|
|
92
|
-
```tsx codeFormat="typescript"
|
|
93
|
-
"use client";
|
|
94
|
-
|
|
95
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
```javascript codeFormat="esm"
|
|
99
|
-
"use client";
|
|
100
|
-
|
|
101
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
```javascript codeFormat="commonjs"
|
|
105
|
-
"use client";
|
|
106
|
-
|
|
107
|
-
const { useIntlayerAsync } = require("next-intlayer");
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Make sure that the importing file is annotated with `"use client"` at the top, if you’re using Next.js App Router with server and client components separated.
|
|
111
|
-
|
|
112
|
-
## Parameters
|
|
113
|
-
|
|
114
|
-
1. **`key`**:
|
|
115
|
-
**Type**: `DictionaryKeys`
|
|
116
|
-
The dictionary key used to identify the localized content block. This key should be defined in your content declaration files.
|
|
117
|
-
|
|
118
|
-
2. **`locale`** (optional):
|
|
119
|
-
**Type**: `Locales`
|
|
120
|
-
The specific locale you want to target. If omitted, the hook uses the locale from the client context.
|
|
121
|
-
|
|
122
|
-
3. **`isRenderEditor`** (optional, defaults to `true`):
|
|
123
|
-
**Type**: `boolean`
|
|
124
|
-
Determines whether the content should be ready for rendering with the Intlayer editor overlay. If set to `false`, the returned dictionary data will exclude editor-specific features.
|
|
125
|
-
|
|
126
|
-
## Return Value
|
|
127
|
-
|
|
128
|
-
The hook returns a dictionary object containing localized content keyed by `key` and `locale`. It also includes an `isLoading` boolean indicating whether a distant dictionary is currently being fetched.
|
|
129
|
-
|
|
130
|
-
## Example Usage in Next.js
|
|
131
|
-
|
|
132
|
-
### Client-Side Component Example
|
|
133
|
-
|
|
134
|
-
```tsx fileName="src/components/AsyncClientComponentExample.tsx" codeFormat="typescript"
|
|
135
|
-
"use client";
|
|
136
|
-
|
|
137
|
-
import { useEffect, type FC } from "react";
|
|
138
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
139
|
-
|
|
140
|
-
export const AsyncClientComponentExample: FC = () => {
|
|
141
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
142
|
-
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
if (isLoading) {
|
|
145
|
-
console.log("Content is loading...");
|
|
146
|
-
}
|
|
147
|
-
}, [isLoading]);
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<div>
|
|
151
|
-
<h1>{title.value}</h1>
|
|
152
|
-
<p>{description.value}</p>
|
|
153
|
-
</div>
|
|
154
|
-
);
|
|
155
|
-
};
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
```jsx fileName="src/components/AsyncClientComponentExample.mjx" codeFormat="esm"
|
|
159
|
-
"use client";
|
|
160
|
-
|
|
161
|
-
import { useEffect } from "react";
|
|
162
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
163
|
-
|
|
164
|
-
const AsyncClientComponentExample = () => {
|
|
165
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
166
|
-
|
|
167
|
-
useEffect(() => {
|
|
168
|
-
if (isLoading) {
|
|
169
|
-
console.log("Content is loading...");
|
|
170
|
-
}
|
|
171
|
-
}, [isLoading]);
|
|
172
|
-
|
|
173
|
-
return (
|
|
174
|
-
<div>
|
|
175
|
-
<h1>{title.value}</h1>
|
|
176
|
-
<p>{description.value}</p>
|
|
177
|
-
</div>
|
|
178
|
-
);
|
|
179
|
-
};
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
```jsx fileName="src/components/AsyncClientComponentExample.csx" codeFormat="commonjs"
|
|
183
|
-
"use client";
|
|
184
|
-
|
|
185
|
-
const { useEffect } = require("react");
|
|
186
|
-
const { useIntlayerAsync } = require("next-intlayer");
|
|
187
|
-
|
|
188
|
-
const AsyncClientComponentExample = () => {
|
|
189
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
190
|
-
|
|
191
|
-
useEffect(() => {
|
|
192
|
-
if (isLoading) {
|
|
193
|
-
console.log("Content is loading...");
|
|
194
|
-
}
|
|
195
|
-
}, [isLoading]);
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<div>
|
|
199
|
-
<h1>{title.value}</h1>
|
|
200
|
-
<p>{description.value}</p>
|
|
201
|
-
</div>
|
|
202
|
-
);
|
|
203
|
-
};
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
**Key Points:**
|
|
207
|
-
|
|
208
|
-
- On initial render, `title` and `description` come from the pre-rendered locale dictionary.
|
|
209
|
-
- While `isLoading` is `true`, a remote request is made in the background to fetch an updated dictionary.
|
|
210
|
-
- Once the fetch completes, `title` and `description` are updated with the newest content, and `isLoading` returns to `false`.
|
|
211
|
-
|
|
212
|
-
## Handling Attribute Localization
|
|
213
|
-
|
|
214
|
-
As with `useIntlayer`, you can retrieve localized attribute values for various HTML properties (e.g., `alt`, `title`, `aria-label`):
|
|
215
|
-
|
|
216
|
-
```tsx
|
|
217
|
-
<img src={title.image.src.value} alt={title.image.alt.value} />
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
## Dictionary Files
|
|
221
|
-
|
|
222
|
-
All content keys must be defined in your content declaration files for type safety and to prevent runtime errors. These files enable TypeScript validation, ensuring you always reference existing keys and locales.
|
|
223
|
-
|
|
224
|
-
Instructions for setting up content declaration files are available [here](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/get_started.md).
|
|
225
|
-
|
|
226
|
-
## Further Information
|
|
227
|
-
|
|
228
|
-
- **Intlayer Visual Editor:**
|
|
229
|
-
Integrate with the Intlayer visual editor for managing and editing content directly from the UI. More details [here](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md).
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
**In summary**, `useIntlayerAsync` is a powerful client-side hook designed to enhance the user experience and maintain content freshness by marrying pre-rendered dictionaries with asynchronous dictionary updates. By leveraging `isLoading` and TypeScript-based content declarations, you can seamlessly integrate dynamic, localized content into your Next.js applications.
|
|
234
|
-
|
|
235
|
-
## Doc History
|
|
236
|
-
|
|
237
|
-
| Version | Date | Changes |
|
|
238
|
-
| ------- | ---------- | ------------ |
|
|
239
|
-
| 5.5.10 | 2025-06-29 | Init history |
|