Skip to content

Instantly share code, notes, and snippets.

@albertBarsegyan
Created October 3, 2021 15:44
Show Gist options
  • Save albertBarsegyan/36a6621c720ce4fe85eacf189020ed86 to your computer and use it in GitHub Desktop.
Save albertBarsegyan/36a6621c720ce4fe85eacf189020ed86 to your computer and use it in GitHub Desktop.
locale links
import React from 'react';
import Link from 'next/link';
import { useRouter } from 'next/dist/client/router';
export default function Test() {
const { locales, asPath } = useRouter();
return (
<div>
{locales.map((localeName) => {
return (
<div key={localeName}>
<Link href={asPath} passHref locale={localeName}>
<a>{localeName}</a>
</Link>
</div>
);
})}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment