Docs / Get started

Setup prompts for coding agents

These are the prompts the Eachlang dashboard gives you in Setup → AI prompt. The dashboard fills in your languages, your site URL and your public key; copy the prompt from there when you can. If you copy it from this page, replace every value in angle brackets first: <source> is your site's language code (for example en), <targets> the languages to add (for example fr, de), <first target> the first of them, plus your site URL and your public key.

The prompt installs one small package and tells your agent exactly how to use it:

Your app Prompt Package
Lovable, TanStack Start Lovable / TanStack Start @eachlang/tanstack
Next.js App Router (also v0, not tested yet there) Next.js App Router @eachlang/next

Both packages are MIT-licensed. They also install @eachlang/switcher, the language switcher. Bolt (Vite + React without TanStack Start): no prompt yet. For websites built with Webflow, WordPress, Squarespace or plain HTML, use the DNS setup instead (Setup guide).

Before you paste: commit your code or note the current version in your builder's history, so you can undo the whole change in one step (Pause, roll back or remove Eachlang).

What to expect: target-language pages show your original text until Eachlang has translated it. That is normal. Your agent must not write translations itself; if it starts, stop it and point it to Rule 0 of the prompt.

Lovable / TanStack Start

text
Add multilingual support to this app with Eachlang. Do not remove, rewrite or reword existing content.

Rule 0: Do NOT write translations yourself. Never translate text in code, in JSON/locale files, in
the snapshot or in a strings object, and do not add i18next, Paraglide or any other i18n library.
Eachlang translates every string; until it does, target-language pages show the original text.
That is expected - do not "fix" it.

Settings: source language = <source>, target languages = <targets>,
site URL = <https://yoursite.com>, Eachlang API = https://api.eachlang.com,
Eachlang public key = <pk_... from your dashboard> (public, read-only; not a secret).

1. Install: npm i @eachlang/tanstack   (do not copy or rewrite the package code; do not add other i18n deps)
2. Create eachlang.config.ts exporting { sourceLang, targetLangs, siteUrl, publicKey, apiBase,
   timeoutMs: 800, missingTimeoutMs: 5000 }.
   Read the key and the API address on the server only, from process.env.EACHLANG_PUBLIC_KEY and
   process.env.EACHLANG_API_BASE (no VITE_ prefix: they are not secrets, but the browser never needs
   them), and add both variables.
3. Routing: the source language stays at the root with NO prefix. Target languages live under
   an optional path segment: move page route files under src/routes/{-$lang}/ so /about and /de/about
   both match. Keep __root.tsx, API/server routes and static files where they are.
4. Load translations ON THE SERVER. Create src/eachlang.functions.ts (NOT *.server.ts: TanStack Start
   refuses to build when client code imports a *.server.* file) with two server functions; the
   Eachlang client is created INSIDE the handler (never at module top level of client code):
     import { createServerFn } from '@tanstack/react-start';
     import { createEachlang } from '@eachlang/tanstack/server';
     let e; const client = () => (e ??= createEachlang({ ...cfg, publicKey: process.env.EACHLANG_PUBLIC_KEY,
                                                          apiBase: process.env.EACHLANG_API_BASE }));
     export const loadTranslations = createServerFn({ method: 'GET' }).validator(...)
       .handler(async ({ data }) => client().getTranslations(data.lang, { preview: data.preview }));   // status, strings, languages, preview, robots
     export const reportMissingFn = createServerFn({ method: 'POST' }).validator(...)
       .handler(async ({ data }) => { await client().reportMissing(data.lang, data.keys, data.path); });
   Call loadTranslations from the {-$lang} route loader. `languages` is the list of ACTIVE target
   languages from the Eachlang manifest. Private-language preview: pass
   preview: readPreviewToken({ url: <request URL>, cookie: <Cookie header> }) (from @eachlang/tanstack;
   it reads ?eachlang_preview= or the eachlang_preview cookie, server side only) as data.preview.
   Never fetch translations in useEffect or in the browser.
   Rules for any code that calls the Eachlang API (the package follows them; so must your code):
   - never request bundle/{lang} while the manifest version is unknown (null); use the fallbacks;
   - strings missing from the dictionary are reported through reportMissingFn: EachlangProvider calls it
     WITHOUT awaiting, but the server function AWAITS its POST to /missing (on Cloudflare Workers an
     un-awaited fetch is cancelled), with missingTimeoutMs, never on the page render path;
   - a string counts as reported only after a 2xx response, so a failed report is sent again (on 429
     wait for Retry-After; on any other 4xx do not resend that batch).
5. In the {-$lang} route (beforeLoad/loader), in this order:
   - lang missing -> source language;
   - lang equals the source language -> redirect (308) to the unprefixed path;
   - lang not in <targets> -> notFound();
   - status === "paused", or lang is in <targets> but NOT in `languages` and not preview -> redirect (307) to the
     same path in the source language (temporary: the language may come back).
   Never show an error page because of Eachlang: getTranslations never throws and falls back to the
   last known translations and language list, then to the snapshot, then to the original text and
   <targets>. An unreachable API never disables a language.
6. Wrap the {-$lang} layout route's component in
   <EachlangProvider lang={lang} strings={strings} sourceLang={cfg.sourceLang} onMissing={(d) => reportMissingFn({ data: d })}>
   (EachlangProvider and useT from @eachlang/tanstack; strings come from that route's loader).
   Wrap every user-visible string in t("…") from useT(), using
   the ORIGINAL text as the key - never put a translation inside t(). Also wrap alt, title, placeholder,
   aria-label, <title> and meta description. Do not wrap brand names, code, URLs or user-generated content.
   Dynamic values stay placeholders inside the key: t("{count} in cart", { count }) - never concatenate
   pieces or call .replace() on the result; translations keep {count}, {name} etc. unchanged.
   head() cannot call useT(): translate <title> and meta description in the {-$lang} loader with
   makeT(strings) from @eachlang/tanstack, call reportMissingFn for t.missing, and return them for head().
   If existing text is not in <source> (e.g. a Turkish heading on an English site), wrap it unchanged,
   do not translate it, and list it in your report under "Not in source language".
7. Use ONE list of alternates, built for the CURRENT path (not in the loader: the {-$lang} loader does
   not re-run when only the page changes, so a list made there goes stale after client navigation):
     alternates = alternatesList(cfg, pathWithoutLangPrefix, tr)   // from @eachlang/tanstack; tr = loader data
   in the component take the path from useLocation(), in head() from matches[matches.length - 1].pathname.
   It is [{ lang, href }], absolute, source + ACTIVE targets; source only when paused. Do not build these
   URLs yourself.
   Use this list everywhere below; hreflangLinks(alternates) from @eachlang/tanstack adds x-default.
   In src/routes/__root.tsx render <html lang={lang}> (read lang from the {-$lang} param, e.g.
   useParams({ strict: false }); source language when absent). In the {-$lang} route head():
   links: [...hreflangLinks(alternates), { rel: 'canonical', href: <this page, this language> }].
   When the loader result has preview: true, also add meta: [{ name: 'robots', content: tr.robots }]
   (it is 'noindex, nofollow'); never add it otherwise.
8. Language switcher: render <LanguageSwitcher> from @eachlang/tanstack in the layout of the {-$lang}
   route, fed by the SAME list:
     <LanguageSwitcher languages={alternates} current={lang} label={t("Language")} />
   It renders identical HTML on the server and the client (no hooks), shows each language in its own
   name, marks the current one with aria-current, ignores x-default and renders nothing when only one
   language is active. Do not wrap language names in t(), do not use flags, do not build your own
   switcher. Internal links and every redirect() (in beforeLoad, loaders and server functions) must
   keep the current language prefix: pass params: { lang }.
9. Multilingual sitemap: serve /sitemap.xml from a server route OUTSIDE the {-$lang} folder (e.g.
   src/routes/sitemap[.]xml.ts). If the app already has a sitemap (route or public/sitemap.xml),
   replace it with this generated one and keep every URL it listed. One <url> per page per language
   (source + active targets; source only when paused), <loc> absolute, and inside each <url> the same
   <xhtml:link rel="alternate" hreflang="…" href="…"/> set as the page head, x-default included
   (urlset declares xmlns:xhtml="http://www.w3.org/1999/xhtml"). List every static route; for dynamic
   routes use the same data source the pages use, or leave them out and say so in the report.
   Content-Type: application/xml. Add "Sitemap: <https://yoursite.com>/sitemap.xml" to public/robots.txt
   (create it if missing; do not change existing rules).
10. Add a script "eachlang:snapshot": "eachlang snapshot" to package.json and run it once; commit the
   generated eachlang/snapshot/*.json files (offline fallback; they are produced by Eachlang - do not
   edit them).
11. Append the "Eachlang i18n rules" section below to AGENTS.md at the repo root (create it if missing).
12. Verify and report. npx tsc --noEmit passes with no errors in the files you changed (fix them).
   Open /<first target>/: no hydration warnings in the console, buttons work,
   client-side navigation stays in the language, clicking another language in the switcher opens the
   same page in that language. Untranslated text on target pages is expected (Rule 0).
   Then read the SERVER-RENDERED HTML (fetch the URL or view-source on the live or preview URL - not
   the DOM after hydration) of: the home page, /<first target>/ and one inner page in both
   languages. Finish your reply with this table, one row per URL, copying values exactly as served:

   | URL | HTTP | <html lang> | canonical | hreflang (code -> href) | x-default | in sitemap |

   Below it: the sitemap URL with its HTTP status and number of <url> entries, and the robots.txt
   Sitemap line. Mark any row where an href is relative, the page does not list itself, canonical
   points elsewhere, the switcher URLs differ from hreflang, or an active language is missing.
   If you cannot fetch a URL, write "not checked" in that row - never fill in expected values.

Next.js App Router

text
Add multilingual support to this Next.js App Router app with Eachlang. Do not remove, rewrite or
reword existing content.

Rule 0: Do NOT write translations yourself. Never translate text in code, in JSON/locale files, in
the snapshot or in a strings object, and do not add next-intl, i18next or any other i18n library.
Eachlang translates every string; until it does, target-language pages show the original text.
That is expected - do not "fix" it.

Settings: source language = <source>, target languages = <targets>,
site URL = <https://yoursite.com>, Eachlang API = https://api.eachlang.com,
Eachlang public key = <pk_... from your dashboard> (public, read-only; not a secret).

1. Install: npm i @eachlang/next   (do not copy or rewrite the package code; do not add other i18n deps)
2. Create eachlang.config.ts exporting { sourceLang, targetLangs, siteUrl, publicKey, apiBase,
   timeoutMs: 800, missingTimeoutMs: 5000 }.
   Read the key and the API address on the server only, from process.env.EACHLANG_PUBLIC_KEY and
   process.env.EACHLANG_API_BASE (no NEXT_PUBLIC_ prefix: they are not secrets, but the browser never
   needs them), and add both variables. Then create lib/eachlang.ts, the ONLY file that creates the client:
     import { createEachlang } from '@eachlang/next/server';
     import cfg from '../eachlang.config';
     export const { getTranslations, reportMissing, localePath, alternates, config } = createEachlang(cfg);
     export { makeT } from '@eachlang/next';
   and app/[lang]/eachlang-actions.ts (Server Action for Client Components):
     'use server';
     import { reportMissing } from '@/lib/eachlang';
     export async function reportMissingAction({ lang, keys, path }) { await reportMissing(lang, keys, path); }
3. Routing: move pages and layouts in app/ under app/[lang]/ (the root layout becomes
   app/[lang]/layout.tsx). Keep app/api/, other route handlers, sitemap.ts, robots.ts and
   icon/favicon files at the app/ root.
   Add proxy.ts (Next 16; middleware.ts on Next 15 or earlier) that:
   - leaves /<target>/… untouched,
   - redirects /<source>/… to the unprefixed path with 308,
   - REWRITES (not redirects) every other path to /<source>/… so the source language stays at the root,
   - skips _next, /api/ and every path containing a dot (public/ files, robots.txt, sitemap.xml,
     llms.txt), e.g. matcher: ['/((?!_next|api/|.*\\..*).*)'],
   - sets the request headers x-eachlang-path (path without the language prefix) and x-eachlang-url
     (the full request URL, used for the private-language preview link).
   Do not redirect based on Accept-Language.
4. In app/[lang]/layout.tsx: notFound() if lang is neither the source nor in <targets>;
   const tr = await getTranslations(lang, { preview }) from lib/eachlang (server only), where
   preview = readPreviewToken({ url: <x-eachlang-url header>, cookie: <Cookie header> }) (readPreviewToken
   from @eachlang/next; proxy.ts sets x-eachlang-url to the full request URL). tr.languages is
   the list of ACTIVE target languages from the Eachlang manifest. If lang is not the source language
   and (tr.status === "paused" or (lang is not in tr.languages and !tr.preview)), redirect() (307) to the same path in the
   source language (get the path from the x-eachlang-path header that proxy.ts sets on every request).
   Render <html lang={lang}> and wrap children in
   <EachlangProvider lang={lang} strings={tr.strings} sourceLang={config.sourceLang}
     onMissing={reportMissingAction}>   (EachlangProvider from @eachlang/next).
   getTranslations never throws: it falls back to the last known translations and language list, then
   the snapshot, then the original text and <targets>. An unreachable API never disables a language.
   Never show an error page because of Eachlang.
   Rules for any code that calls the Eachlang API (the package follows them; so must your code):
   - never request bundle/{lang} while the manifest version is unknown (null); use the fallbacks;
   - strings missing from the dictionary are reported from the server: in Server Components inside
     after() from next/server, from Client Components through reportMissingAction, which
     EachlangProvider calls without awaiting; the server code AWAITS its POST to /missing (serverless and Workers runtimes cancel an
     un-awaited fetch once the response is sent), with missingTimeoutMs, never on the render path;
   - a string counts as reported only after a 2xx response, so a failed report is sent again (on 429
     wait for Retry-After; on any other 4xx do not resend that batch).
5. Server Components (and generateMetadata), in this exact shape:
     const tr = await getTranslations(lang);
     const t = makeT(tr.strings, { collect: lang !== config.sourceLang && tr.status === 'active' });
     ... t("…") ...
     if (t.missing.length) after(() => reportMissing(lang, t.missing, path));   // after from next/server
   Use t("…") with the ORIGINAL text as the key - never put a translation inside t().
   Client Components: const t = useT() from @eachlang/next (reports its own missing strings through
   the provider). Never translate in useEffect. Also wrap alt, title, placeholder, aria-label and metadata (title,
   description). Do not wrap brand names, code, URLs or user-generated content.
   Dynamic values stay placeholders inside the key: t("{count} in cart", { count }) - never concatenate
   pieces or call .replace() on the result; translations keep {count}, {name} etc. unchanged.
   generateMetadata uses the same makeT + after(reportMissing) shape, so title and description are
   reported as missing like any other string. If existing text is not in <source> (e.g. a Turkish heading on an English site),
   wrap it unchanged, do not translate it, and list it in your report under "Not in source language".
6. generateMetadata in app/[lang]/layout.tsx (and pages with their own path):
     return { alternates: alternates(lang, path, tr), ...(tr.preview ? { robots: tr.robots } : {}) };
   (path from the x-eachlang-path header). It returns canonical (absolute, this language) and
   languages = source, every ACTIVE target language and "x-default", absolute URLs, same path; when
   paused, only the source language and x-default. Do not build these URLs yourself.
7. Language switcher: render <LanguageSwitcher> from @eachlang/next in the site header (or footer),
   once per page. Pass it the SAME data you used for hreflang so both always list identical URLs:
     import { LanguageSwitcher } from '@eachlang/next';
     <LanguageSwitcher languages={alternates(lang, path, tr).languages} current={lang} label={t("Language")} />
   i.e. the same alternates(lang, path, tr) call as generateMetadata (x-default is ignored). In a
   layout, get path from the x-eachlang-path header; never hard-code it.
   It works in Server and Client Components (no hooks, no effects), shows each language in its own
   name (Deutsch, Français), marks the current one with aria-current and renders nothing when only
   one language is active. Use variant="menu" for a compact dropdown (<details>, no JS).
   Do not wrap language names in t(), do not replace them with flags, and do not build your own switcher.
   Style it with the site's own CSS (classes .eachlang-switcher, .eachlang-switcher__link) or import
   '@eachlang/next/switcher.css' for neutral defaults. Internal <Link>s and every redirect(),
   permanentRedirect() and router.push() must keep the current language prefix (none for the source):
   use localePath(lang, "/about") from lib/eachlang.
8. Multilingual sitemap: create app/sitemap.ts if it does not exist, otherwise update it and keep
   every URL it already lists. One entry per page per language (source + active targets; source only
   when paused), url absolute, alternates.languages = alternates(lang, path, tr).languages (step 6).
   List every static route; for dynamic routes use the same data source the pages use, or leave them
   out and say so in the report. In app/robots.ts (create if missing; keep existing rules) set
   sitemap: "<https://yoursite.com>/sitemap.xml". If a static public/sitemap.xml or public/robots.txt exists,
   remove it so it does not shadow the generated one.
9. Add "eachlang:snapshot": "eachlang snapshot" to package.json scripts, run it once and commit
   eachlang/snapshot/*.json (produced by Eachlang - do not edit them).
10. Append the "Eachlang i18n rules" section below to AGENTS.md at the repo root (create it if missing).
11. Verify and report: npm run build and npx tsc --noEmit pass with no errors in the files you
   changed (fix them); /<first target> has the right <html lang>; no hydration
   warnings; buttons work; client navigation stays in the language; /<source>/… redirects to the root
   path; clicking another language in the switcher opens the same page in that language. Untranslated
   text on target pages is expected (Rule 0).
   Then read the SERVER-RENDERED HTML (curl the URL or view-source on the deployed or `next start`
   URL - not the DOM after hydration) of: the home page, /<first target> and one inner page in both
   languages. Finish your reply with this table, one row per URL, copying values exactly as served:

   | URL | HTTP | <html lang> | canonical | hreflang (code -> href) | x-default | in sitemap |

   Below it: the sitemap URL with its HTTP status and number of <url> entries, and the robots.txt
   Sitemap line. Mark any row where an href is relative, the page does not list itself, canonical
   points elsewhere, the switcher URLs differ from hreflang, or an active language is missing.
   If you cannot fetch a URL, write "not checked" in that row - never fill in expected values.
   Troubleshooting: if `next start -H 127.0.0.1` (or any host other than localhost) answers every
   source-language page with an endless 308 loop, start it without -H (or with -H localhost) and
   check again; the rewrite in proxy.ts must stay on the same origin. Do not change the redirect rules.

The AGENTS.md section

Step 11 (Lovable) and step 10 (Next.js) add this section to AGENTS.md at the root of your repo, with your languages filled in. Coding agents read that file before every task, so new text keeps going through t("…").

markdown
## Eachlang i18n rules
This app is translated with Eachlang (source: <source>; targets: <targets>).
- Wrap every new user-visible string in t("…") (server: makeT(tr.strings) after getTranslations(lang); client: useT()). The original
  text is the key. Include alt, title, placeholder, aria-label and page metadata; page <title> and
  meta description are translated on the server (loader / generateMetadata), not with useT().
- Dynamic values stay placeholders in the key: t("{count} in cart", { count }). Never concatenate
  pieces or call .replace() on a translated string.
- Write new text in <source> only; text in another language is not translated - flag it.
- Never write translations yourself (no locale files, no translated text in code); Eachlang
  translates. Untranslated text on target pages is expected until Eachlang publishes.
- Never translate in useEffect or in the browser; translations are loaded on the server in the
  [lang] layout / {-$lang} route loader.
- New pages go under the language segment (app/[lang]/… or src/routes/{-$lang}/…). Internal links
  and every redirect() keep the current language prefix (TanStack: pass params: { lang }). The
  source language has no prefix.
- Missing-string reports: the server code AWAITS the POST to Eachlang (Cloudflare Workers and
  serverless cancel un-awaited fetches); the browser never awaits it. Do not make it fire-and-forget.
- After changes, npx tsc --noEmit must pass.
- Every page keeps <html lang>, hreflang alternates (+ x-default) and a self canonical. New pages
  are added to the multilingual sitemap with the same alternates. The language switcher uses the
  same alternates list; do not build another one.
- Do not add error handling that shows an error page when Eachlang is unavailable; the library
  falls back to the last known translation or the original text.
- After adding many strings, run `npm run eachlang:snapshot` and commit eachlang/snapshot/.
- Do not remove this section unless the user asks to remove Eachlang.

Eachlang vs Weglot's React package

Weglot released its own React and Next.js package, @weglot/translate-react, in October 2026. Three differences matter for a Next.js site:

@eachlang/next @weglot/translate-react 0.2.1
Language URLs and SEO Every language has its own URL (/fr/…), with hreflang tags and a switcher that link the same addresses, so search engines can index each language. "The visitor's language is kept in a locale cookie; URLs do not change." The README does not mention hreflang.
Your build Nothing is translated at build time. Pages fall back from the API to the last known translation, a snapshot, then your source text; a translation problem never fails a build or a page. Default build mode: "the build fails if translation fails". cache-only mode: "the build fails if the local cache is incomplete".
Fixing a translation Edit it in the Eachlang dashboard; it is live within about a minute (60-second cache by default), no redeploy. Translations "appear in your Weglot dashboard where you can review and edit them", and are written into your build (public/translations/<locale>.json, "written by every build"). The README does not say whether a dashboard edit reaches the site without a new build.

Source: the @weglot/translate-react README on npm, version 0.2.1, read on 11 November 2026. Weglot may change this in later versions; tell us at hello@eachlang.com if something here is out of date.

How these prompts were tested

On 8 November 2026 each package was installed from its release tarball (npm pack, version 0.1.0) into a sample app built the way the prompt describes (Next.js 16.4, TanStack Start 1.169) and checked in Chromium against a test API, 13 of 13 checks passing for each: translated pages rendered on the server, missing strings reported once, client-side navigation kept the language, the switcher and hreflang listed the same URLs, the last known translation was used when the API was down, and pause sent visitors to the original pages. The sample apps were written by us following the prompt; a coding agent running these exact prompts on a new app has not been tested yet with the packaged versions. On 11 November 2026 both sample apps were installed from npm (@eachlang/next and @eachlang/tanstack 0.1.1) and passed the same checks again.

Lovable, TanStack, Next.js, v0 and Bolt are trademarks of their owners. Eachlang is not affiliated with or endorsed by them.