Next.js Discord

Discord Forum

Navigate using Link on Next-intl ?

Answered
West African Lion posted this in #help-forum
Open in Discord
Avatar
West African LionOP
Hey guys, im struggling on how to use the current language to navigate dynamiclay through my app.
Can't use ${pathname} on Link, any ideas ?

``
import { useRouter, locales, localePrefix } from "../navigation";
import { useParams } from "next/navigation";
export default function Navigation() {
  const params = useParams();

  console.log(params);
  console.log(locales);
  console.log(localePrefix);

  // const params = useParams();
  // console.log(params);

  return (
    <>
      <div className=" h-32 w-full flex lg:bg-white justify-between lg:justify-around bg-black lg:pr-12 overflow-y-hidden">
        <div className="w-full h-full hidden lg:flex justify-evenly">
          <div className="flex items-center w-5/12">
            <div className="flex  text-xl w-full justify-evenly font-light">
              <Link href="/">
                <span>Home</span>
              </Link>
              <Link href={`/${params}/services` }> // Here //
                <span>Services</span>
              </Link>
              <Link href="/about">
                <span>About</span>
              </Link>
            </div>
`
Answered by Ray
params is an object. Maybe params.lang?
View full answer

7 Replies

Avatar
params is an object. Maybe params.lang?
Answer
Avatar
West African LionOP
I get this
Image
Avatar
yes params is an object
Avatar
West African LionOP
Yeah
It worked
Thanks men !!
Avatar
np