CompilerOptions
CompilerOptions =
object
Defined in: compiler-options.ts:52
Properties
cleanOutdir?
optionalcleanOutdir:boolean
Defined in: compiler-options.ts:430
Whether to clean the output directory before writing the new files.
Default
true
cookieDomain?
optionalcookieDomain:string
Defined in: compiler-options.ts:207
The host to which the cookie will be sent. If undefined or empty, the domain attribute is omitted from the cookie, scoping it to the exact current domain only (no subdomains). If specified, the cookie will be available to the specified domain and all its subdomains.
Use this when you need cookies to be shared across subdomains (e.g., between app.example.com and api.example.com).
The default behavior (no domain) ensures better compatibility with server-side cookies that don't specify a domain attribute.
Example
// Default: exact domain only (compatible with server-side cookies)
cookieDomain: undefined // Cookie: "PARAGLIDE_LOCALE=en; path=/; max-age=34560000"
// Subdomain sharing: available across all subdomains
cookieDomain: "example.com" // Cookie: "PARAGLIDE_LOCALE=en; path=/; max-age=34560000; domain=example.com"
Default
"" (no domain attribute, exact domain only)
cookieMaxAge?
optionalcookieMaxAge:number
Defined in: compiler-options.ts:187
The max-age in seconds of the cookie until it expires.
Default
60 * 60 * 24 * 400
cookieName?
optionalcookieName:string
Defined in: compiler-options.ts:181
The name of the cookie to use for the cookie strategy.
Default
'PARAGLIDE_LOCALE'
cookieSameSite?
optionalcookieSameSite:"lax"|"strict"|"none"
Defined in: compiler-options.ts:226
The SameSite attribute of the cookie.
If undefined, the attribute is omitted and the browser applies its own default.
Set it when the cookie must match a policy, for example the one a server uses
when it writes the same cookie with Set-Cookie.
"none" requires cookieSecure to be true or "auto" because browsers
reject SameSite=None cookies without the Secure attribute. With "auto",
the cookie is still dropped on plain http:// pages.
Example
cookieSameSite: "lax" // Cookie: "PARAGLIDE_LOCALE=en; path=/; max-age=34560000; samesite=lax"
Default
undefined (no samesite attribute)
cookieSecure?
optionalcookieSecure:boolean|"auto"
Defined in: compiler-options.ts:248
Whether the cookie gets the Secure attribute.
truealways adds it. Pages served over plainhttp://cannot set aSecurecookie, except onlocalhost."auto"adds it only when the page is served overhttps:, so the cookie keeps working on plainhttp://hosts other than localhost, like a LAN IP or an internal staging server. WithcookieSameSite: "none", the cookie still needshttps:.falsenever adds it.
Server code that reads cookieSecure from the runtime has to resolve "auto"
itself, for example from the request protocol or X-Forwarded-Proto.
Example
cookieSecure: "auto" // on https: "PARAGLIDE_LOCALE=en; path=/; max-age=34560000; secure"
Default
false
disableAsyncLocalStorage?
optionaldisableAsyncLocalStorage:boolean
Defined in: compiler-options.ts:347
Replaces AsyncLocalStorage with a synchronous implementation.
Leave AsyncLocalStorage enabled by default. This option is a
compatibility fallback for runtimes that do not provide
AsyncLocalStorage or node:async_hooks.
⚠️ WARNING: Only use this option when your runtime also guarantees request isolation. Disabling AsyncLocalStorage in multi-request server environments risks cross-request pollution where state from one request could leak into another concurrent request.
emitGitIgnore?
optionalemitGitIgnore:boolean
Defined in: compiler-options.ts:361
If emitGitIgnore is set to true a .gitignore file will be emitted in the output directory. Defaults to true.
- outdir/
- messages/
+ - .gitignore
- messages.js
- runtime.js
Default
true
emitPrettierIgnore?
optionalemitPrettierIgnore:boolean
Defined in: compiler-options.ts:262
If emitPrettierIgnore is set to true a .prettierignore file will be emitted in the output directory. Defaults to true.
- outdir/
- messages/
+ - .prettierignore
- messages.js
- runtime.js
Default
true
emitReadme?
optionalemitReadme:boolean
Defined in: compiler-options.ts:279
If emitReadme is set to true a README.md file will be emitted in the output directory. Defaults to true.
The README helps LLMs understand the compiled output. See https://llmstxt.org/ for format guidelines.
- outdir/
- messages/
+ - README.md
- messages.js
- runtime.js
Default
true
emitTsDeclarations?
optionalemitTsDeclarations:boolean
Defined in: compiler-options.ts:301
Emit .d.ts files directly for the generated output.
Useful when allowJs: true cannot be set in your tsconfig.json
(e.g., due to project constraints or conflicting compiler options), or when
an editor language server caches stale JSDoc types for generated messages.
Declarations are generated from message metadata and runtime declaration templates. No TypeScript installation is required.
Example
await compile({
project: "./project.inlang",
outdir: "./src/paraglide",
emitTsDeclarations: true,
});
Default
false
experimentalStaticLocale?
optionalexperimentalStaticLocale:string
Defined in: compiler-options.ts:175
Compile-time locale constant used for per-locale tree-shaking.
This is experimental and opt-in. It should be a JavaScript expression
(not a quoted literal) that resolves to a locale or undefined at build time.
You can pass a string literal (e.g. "de") for programmatic builds, or an
injected env/define expression for bundler-driven builds.
High-level flow for per-locale builds:
client request (/) | v +----------------------+ | detect locale | | (cookie/Accept-L) | | pick build prefix | +----------------------+ | if "de" v serve dist/de/... <----> serve dist/en/... (HTML + assets) (HTML + assets)
See
https://github.com/opral/paraglide-js/issues/88#issuecomment-3634754638
Examples
// Vite define
experimentalStaticLocale: "typeof __PARAGLIDE_STATIC_LOCALE__ === 'undefined' ? undefined : __PARAGLIDE_STATIC_LOCALE__"
// Programmatic compile (literal)
experimentalStaticLocale: '"de"'
fs?
optionalfs:any
Defined in: compiler-options.ts:437
The file system to use. Defaults to await import('node:fs').
Useful for testing the paraglide compiler by mocking the fs.
includeEslintDisableComment?
optionalincludeEslintDisableComment:boolean
Defined in: compiler-options.ts:334
Whether to include an eslint-disable comment at the top of each .js file.
Default
true
isDevelopment?
optionalisDevelopment:string
Defined in: compiler-options.ts:141
JavaScript expression controlling development-only runtime diagnostics.
Bundler integrations set this for their development and production modes. Standalone compilation keeps diagnostics enabled unless explicitly disabled. Set to "false" for production output to allow dead-code elimination.
Default
"true"
isServer?
optionalisServer:string
Defined in: compiler-options.ts:131
Tree-shaking flag if the code is running on the server.
Dependent on the bundler, this flag must be adapted to enable tree-shaking.
Example
// vite
isServer: "import.meta.env.SSR"
Default
typeof window === "undefined"
lazyUrlPatternPolyfill?
optionallazyUrlPatternPolyfill:boolean
Defined in: compiler-options.ts:320
Load the URLPattern polyfill only when the target runtime lacks URLPattern.
Applies when custom urlPatterns or routeStrategies require matching.
Enabling this emits a conditional top-level await import(...). Requires
Vite 7+ or another ESM toolchain and runtime supporting top-level await.
CommonJS and IIFE output are not supported when enabled. Importers wait for
initialization automatically; routing APIs remain synchronous.
Defaults to a static polyfill import. Built-in default routing without route strategies does not include the polyfill in either mode.
Default
false
localStorageKey?
optionallocalStorageKey:string
Defined in: compiler-options.ts:118
The name of the localStorage key to use for the localStorage strategy.
Default
'PARAGLIDE_LOCALE'
messageModuleSize?
optionalmessageModuleSize:number
Defined in: compiler-options.ts:424
Messages per generated module in the message-modules layout. Values above one group messages into shards and preserve messages.js exports, while replacing per-message module paths with shard files. Defaults to one. Locale-specialized builds currently require the default value.
Default
1
outdir
outdir:
string
Defined in: compiler-options.ts:76
The path to the output directory.
Example
await compile({
project: "./project.inlang",
+ outdir: "./src/paraglide"
})
outputStructure?
optionaloutputStructure:"locale-modules"|"message-modules"|"virtual-modules"
Defined in: compiler-options.ts:415
The outputStructure defines how modules are structured in the output.
message-modules- Each module is a physical message file. Default for the CLI.virtual-modules- Individual messages served by Vite, with combined declarations. Default for Vite builds; requires the Vite plugin.locale-modules- Each module is a locale.
Vite serve and Vitest use locale-modules to reduce HTTP requests. Vite builds
use virtual-modules, keeping public entry points physical while avoiding
individual message files. Other bundler plugins use locale-modules in
development and message-modules in production. Explicit layouts override
these defaults.
message-modules
Messages have their own module which eases tree-shaking for bundlers.
- outdir/
- messages/
+ - blue_elephant_tree/
+ - index.js
+ - en.js
+ - fr.js
+ - sky_phone_bottle/
+ - index.js
+ - en.js
+ - fr.js
- ...
- messages.js
- runtime.js
locale-modules
Messages are bundled in a per locale module. Bundlers often struggle with tree-shaking this structure,
which can lead to more inefficient tree-shaking and larger bundle sizes compared to message-modules.
The benefit are substantially fewer files which is needed in large projects.
- outdir/
- messages/
+ - de.js
+ - en.js
+ - fr.js
- ...
- messages.js
- runtime.js
Default
"message-modules"
project
project:
string
Defined in: compiler-options.ts:64
The path to the inlang project.
Example
await compile({
+ project: "./project.inlang",
outdir: "./src/paraglide"
})
routeStrategies?
optionalrouteStrategies:RouteStrategy[]
Defined in: compiler-options.ts:112
Route-level strategy overrides.
Routes are matched in declaration order. The first matching rule wins.
match uses URLPattern syntax.
strategy: Override locale resolution for the matched route.exclude: true: Skip i18n middleware behavior for the matched route.
Example
routeStrategies: [
{ match: "/dashboard/:path(.*)?", strategy: ["cookie", "baseLocale"] },
{ match: "/api/:path(.*)?", exclude: true }
]
strategy?
optionalstrategy:Runtime["strategy"]
Defined in: compiler-options.ts:94
The strategy to use for getting the locale.
The order of the strategy defines the precedence of matches.
For example, in ['url', 'cookie', 'baseLocale'], the locale will be
first tried to be detected in the url, then in a cookie, and finally
fallback to the base locale.
The default ensures that the browser takes a cookie approach, server-side takes the globalVariable (because cookie is unavailable), whereas both fallback to the base locale if not available.
Custom strategies with the pattern custom-[A-Za-z0-9_-]+ are supported.
Default
["cookie", "globalVariable", "baseLocale"]
trailingSlash?
optionaltrailingSlash:"always"|"never"
Defined in: compiler-options.ts:328
Controls trailing slash canonicalization for localized URLs.
Canonicalization happens before URL pattern matching and after URL localization. If omitted, Paraglide keeps its existing trailing slash behavior.
urlPatterns?
optionalurlPatterns:Runtime["urlPatterns"]
Defined in: compiler-options.ts:305
https://paraglidejs.com/strategy#url
RouteStrategy
RouteStrategy = {
exclude?:never;match:string;strategy:Runtime["strategy"]; } | {exclude:true;match:string;strategy?:never; }
Defined in: compiler-options.ts:3
Type Declaration
{ exclude?: never; match: string; strategy: Runtime["strategy"]; }
exclude?
optionalexclude:never
Prevent mutually exclusive configuration (exclude + strategy).
match
match:
string
URLPattern-compatible matcher.
strategy
strategy:
Runtime["strategy"]
Strategy override for matching requests.
{ exclude: true; match: string; strategy?: never; }
exclude
exclude:
true
Exclude matching requests from i18n middleware behavior.
match
match:
string
URLPattern-compatible matcher.
strategy?
optionalstrategy:never
Prevent mutually exclusive configuration (exclude + strategy).
defaultCompilerOptions
constdefaultCompilerOptions:object
Defined in: compiler-options.ts:33
Type Declaration
cleanOutdir
readonlycleanOutdir:true=true
cookieDomain
readonlycookieDomain:""=""
cookieMaxAge
readonlycookieMaxAge:number
cookieName
readonlycookieName:"PARAGLIDE_LOCALE"="PARAGLIDE_LOCALE"
disableAsyncLocalStorage
readonlydisableAsyncLocalStorage:false=false
emitGitIgnore
readonlyemitGitIgnore:true=true
emitPrettierIgnore
readonlyemitPrettierIgnore:true=true
emitReadme
readonlyemitReadme:true=true
emitTsDeclarations
readonlyemitTsDeclarations:false=false
includeEslintDisableComment
readonlyincludeEslintDisableComment:true=true
isDevelopment
readonlyisDevelopment:"true"="true"
isServer
readonlyisServer:"typeof window === 'undefined'"="typeof window === 'undefined'"
lazyUrlPatternPolyfill
readonlylazyUrlPatternPolyfill:false=false
localStorageKey
readonlylocalStorageKey:"PARAGLIDE_LOCALE"="PARAGLIDE_LOCALE"
outputStructure
readonlyoutputStructure:"message-modules"="message-modules"
strategy
readonlystrategy: ["cookie","globalVariable","baseLocale"]
