Skip to content

Instantly share code, notes, and snippets.

@fwojciec
Created September 3, 2019 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fwojciec/3d0135265f5551863f9dd85983faa9b7 to your computer and use it in GitHub Desktop.
Save fwojciec/3d0135265f5551863f9dd85983faa9b7 to your computer and use it in GitHub Desktop.
How to build a multilingual website in Next.js #1
// pages/index.tsx
import React from 'react'
import Head from 'next/head'
import { getInitialLocale } from '../translations/getInitialLocale'
import { useRouter } from 'next/dist/client/router'
const Index: React.FC = () => {
const router = useRouter()
React.useEffect(() => {
router.replace('/[lang]', `/${getInitialLocale()}`)
})
return (
<Head>
<meta name="robots" content="noindex, nofollow" />
</Head>
)
}
export default Index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment