next-app-boilerplate/pages/_app.tsx

24 lines
653 B
TypeScript
Raw Normal View History

import '../styles/main.css'
import '@fontsource/open-sans'
import '@fontsource/open-sans/600.css'
import Cookies from 'js-cookie'
import type { AppProps } from 'next/app'
2022-05-16 14:25:01 +02:00
import useTranslation from 'next-translate/useTranslation'
import { useEffect } from 'react'
2022-02-12 23:07:11 +01:00
2022-03-24 01:44:55 +01:00
const MyApp = ({ Component, pageProps }: AppProps): JSX.Element => {
2022-05-16 14:25:01 +02:00
const { lang } = useTranslation()
// 10 years before cookie's expiration
const COOKIE_EXPIRATION = 10 * 365.25 * 24 * 60 * 60
useEffect(() => {
Cookies.set('NEXT_LOCALE', lang, { expires: COOKIE_EXPIRATION })
}, [lang, COOKIE_EXPIRATION])
return <Component {...pageProps} />
}
2022-02-12 23:07:11 +01:00
export default MyApp