Skip to Content
Senri

Language detection

Decide the language of a request with languageDetector()

import { , , type  } from "@senrijs/senri";

const  = <>();

.(({ : ["ja", "en"], : "en" }));
.("/", (, ) => (.("language") === "ja" ? "こんにちは" : "Hello"));
  • It looks at the query (lang), the cookie (language) and Accept-Language, in this order
  • c.get("language") is always one of supportedLanguages. If none matches, it is fallbackLanguage
  • It does not write the cookie. To remember the language, call setCookie() yourself

Options

Prop

Type

On this page