---
title: "SSR API"
description: "Reference server language selection and keeping the browser in sync."
canonical_url: "https://docs.linguana.dev/docs/reference/ssr"
markdown_url: "https://docs.linguana.dev/docs/reference/ssr.md"
x_farming_labs_generated_preamble: true
---

# SSR API
URL: /docs/reference/ssr
LLM index: /llms.txt
Description: Reference server language selection and keeping the browser in sync.

# SSR API

Import server helpers from `@linguanahq/react/ssr`.

## `resolveRequestLocale(input)`

```ts
type ResolveRequestLocaleInput = {
  request: Request;
  override?: string | null;
  userPreference?: string | null;
  supportedLocales: readonly string[];
  defaultLocale: string;
  cookieName?: string;
};
```

Reads the configured cookie (default `linguana_locale`) and `Accept-Language`, then delegates to the shared precedence algorithm. It returns one of the supported matches or the default.

## `createRequestHydrationState(locale, catalogs)`

Returns schema-versioned `LocaleHydrationState` after validating every catalog. Pass it unchanged to `LocaleProvider.hydrationState` on the initial render.

## Precedence

1. Explicit application override.
2. Signed-in preference supplied by the host.
3. First-party cookie.
4. Weighted `Accept-Language` match.
5. Project default.

Exact locale matches win before language-only matches.

## See also

[Server rendering setup](/docs/build-with-code/server-rendering) · [TanStack Start](/docs/getting-started/tanstack-start)

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
