Skip to content

Unable to Use 'router.replace' with Custom Locale Parameter #420

Closed as not planned
@pascal-adk

Description

@pascal-adk

Description

I know this is not directly related to next-intl, but it's recommended in the docs and i need an alternative.
I encountered an issue while attempting to use the 'router.replace' method in combination with a custom 'locale' parameter. However, I received an error message stating, "Argument of type '{ locale: string; }' is not assignable to parameter of type 'Url | undefined'. Object literal may only specify known properties, and 'locale' does not exist in type 'UrlObject'.ts(2345)."

Mandatory reproduction URL (CodeSandbox or GitHub repository)

https://codesandbox.io/p/sandbox/next-intl-bug-template-forked-yow8ep

Reproduction description

  1. Follow the documentation link provided (https://next-intl-docs.vercel.app/docs/routing/navigation#userouter) to learn about the recommended approach for routing with internationalization using 'router.replace'.
  2. Implement the 'router.replace' method with the 'pathname' and 'locale' parameters in your Next.js application as described in the documentation.
  3. Observe the TypeScript error mentioned above when attempting to compile the application.

Expected behaviour

The user should be redirected to the current page with the correct translation provided.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions