> For the complete documentation index, see [llms.txt](https://developers.weglot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.weglot.com/frameworks-and-ai/react/settings.md).

# Settings

Configure the Weglot package from your Next.js or Vite configuration.

Pass these options as the second argument of `withWeglot` (Next.js), or as the argument of `weglotPlugin` (Vite).

| Option                           | Type                            | Default                                                            | Description                                                                                                                                                                       |
| -------------------------------- | ------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey`                         | `string`                        | `WEGLOT_API_KEY` env var                                           | Your Weglot project API key, starting with `pk_`.                                                                                                                                 |
| `sourceRoot`                     | `string`                        | `"src"`                                                            | Root folder of the code to translate. Point it to the folder that contains all your pages and components.                                                                         |
| `useDirective`                   | `boolean`                       | `false`                                                            | Only transform files containing a `'use i18n'` directive. Useful to roll out translation page by page.                                                                            |
| `buildMode`                      | `"translate"` \| `"cache-only"` | `"translate"`                                                      | See [Build modes](#build-modes).                                                                                                                                                  |
| `translationTimeout`             | `number`                        | `300` in a build, `10` in dev                                      | Seconds to wait for translations Weglot is still generating. Also set with `WEGLOT_TRANSLATION_TIMEOUT`.                                                                          |
| `dev.translationServerStartPort` | `number`                        | `60000`                                                            | Port of the local translation server used in dev.                                                                                                                                 |
| `localePersistence`              | cookie config                   | `{ type: "cookie", config: { name: "locale", maxAge: 31536000 } }` | How the visitor's language is stored.                                                                                                                                             |
| `translatableAttributes`         | `Record<string, string[]>`      | `{}`                                                               | Which component props hold text. See [Translate your own component props](https://developers.weglot.com/frameworks-and-ai/react/use-cases.md#translate-your-own-component-props). |

{% hint style="info" %}
Languages are not configured here: they come from your Weglot project.
{% endhint %}

## Build modes

* **`translate`** (default): missing translations are generated through the Weglot API during the build. The build fails if translation fails.
* **`cache-only`**: no network calls. The build fails if the local translation cache is incomplete. Override it for one build with `WEGLOT_BUILD_MODE=cache-only`.

Weglot generates translations with an LLM, so new text can take a moment: the build waits for it up to `translationTimeout`. If some translations are still not ready, the build fails and keeps the ones it received in the local cache. Build again, without the `.next` cache, to pick up where it stopped. In dev, text not ready in time shows in the source language until the next reload.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.weglot.com/frameworks-and-ai/react/settings.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
