Set it up
- 01
Install
One package. lefine/server and lefine/strings import no React and no Next.
terminalbashnpm install lefine - 02
Load and translate
createStrings takes your app id; load returns plain JSON; createTranslator gives you t.
strings.ts// any framework, server or browserimport { createStrings } from "lefine/server";import { createTranslator } from "lefine/strings";const strings = createStrings({ project: "app_..." }); // one per appconst props = await strings.load(locale, ["home"]); // plain JSONconst t = createTranslator({ ...props, namespace: "home" }); - 03
Use it in a component
$derived builds the translator again when the props change.
Home.svelte<script lang="ts"> import { createTranslator } from "lefine/strings"; import type { StringsProps } from "lefine/server"; // props come from your load function: await strings.load(locale, ["home"]) let { props }: { props: StringsProps } = $props(); const t = $derived(createTranslator({ ...props, namespace: "home" }));</script><h1>{t("greeting", { name: "World" })}</h1>