> ## Documentation Index
> Fetch the complete documentation index at: https://anylang.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# App Setup

> Scan strings, wrap your app with the provider, and add a language selector.

## Scan strings

Run the scan command to generate your locale files and runtime helper.

```bash theme={null}
npx anylang scan
```

`scan` creates locale files and the generated runtime without calling an AI provider.

```text theme={null}
locales/
  en.json
  hi.json
  anylang.lock.json
src/
  anylang.ts
```

## Wrap your app

<Tabs>
  <Tab title="Vite" icon="zap">
    Wrap your React tree once with `AnyLangProvider`.

    ```tsx src/main.tsx theme={null}
    import { StrictMode } from "react";
    import { createRoot } from "react-dom/client";
    import { AnyLangProvider } from "@/anylang";
    import { App } from "./App";

    createRoot(document.getElementById("root")!).render(
      <StrictMode>
        <AnyLangProvider>
          <App />
        </AnyLangProvider>
      </StrictMode>
    );
    ```
  </Tab>

  <Tab title="Next.js" icon="triangle">
    Create a client provider.

    ```tsx app/providers.tsx theme={null}
    "use client";

    import { AnyLangProvider } from "@/anylang";

    export function Providers({ children }: { children: React.ReactNode }) {
      return <AnyLangProvider>{children}</AnyLangProvider>;
    }
    ```

    Wrap your root layout.

    ```tsx app/layout.tsx theme={null}
    import { AnyLangProvider } from "@/anylang";

    export default function RootLayout({ children }: { children: React.ReactNode }) {
      return (
        <html lang="en">
          <body>
               <AnyLangProvider>{children}</AnyLangProvider>
          </body>
        </html>
      );
    }
    ```
  </Tab>
</Tabs>

## Add a language selector

Build any selector UI and pass the selected locale to `setLanguage`.

```tsx theme={null}
"use client";

import { useLanguage, type LanguageCode } from "@/anylang";

export function LanguageSelector() {
  const { language, languages, setLanguage } = useLanguage();

  return (
    <select
      value={language}
      onChange={(event) => setLanguage(event.target.value as LanguageCode)}
    >
      {languages.map((language) => (
        <option key={language.code} value={language.code}>
          {language.nativeLabel}
        </option>
      ))}
    </select>
  );
}
```
