Skip to content

Strictly typed useLocale #1377

@amannn

Description

@amannn

Is your feature request related to a problem? Please describe.

Currently, useLocale returns a string. This is mostly fine, but APIs that ask for strictly typed locales (e.g. locale of getPathname currently) make this not easy to assign.

The reason for this is that the locales are passed to a navigation factory function, but not useLocale (which is imported from next-intl).

Describe the solution you'd like

Either all APIs should use a strictly typed locale or none—a mixture requires workarounds.

Similar to strictly typed messages and formats, we could allow the user to provide the list of locales globally. This would work for both global APIs like useLocale as well as the navigation APIs. At this point we could consider registering all global shapes under a single type namespace.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions