Skip to content

Specify type of useLocale #477

Answered by amannn
TommySorensen asked this question in Q&A
Aug 24, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Currently only if you wrap the function:

import {useLocale as useUntypedLocale} from 'next-intl';

export default function useLocale() {
  return useUntypedLocale() as 'en' | 'en-GB';
}

I've been thinking about a way to provide this within the library, as with the App Router, we can guarantee that only known locales are returned. For the Pages Router this was not possible with the way the library is integrated.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@TommySorensen
Comment options

@amannn
Comment options

@stefanprobst
Comment options

Answer selected by TommySorensen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants