dayjs
dayjs copied to clipboard
How to set dayjs global config in next14
Describe the bug
I tried to apply global config by referring to the GitHub issue.
but it does not work.
I'm using next.js 14 app router. Extending day.js globally does not work.
//app/layout.tsx
import React, { ReactNode } from 'react';
import type { Metadata, Viewport } from 'next';
import '@/src/common/utils/dayjs';
//src/common/utils/dayjs
import dayjs from 'dayjs';
import ko from 'dayjs/locale/ko';
import timezone from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
import isoWeek from 'dayjs/plugin/isoWeek';
import duration from 'dayjs/plugin/duration';
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(isoWeek);
dayjs.extend(duration);
dayjs.locale(ko);
dayjs.tz.setDefault('Asia/Seoul');
export default dayjs
//tsconfig.ts
{
"compilerOptions": {
"target": "ES2018",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"allowSyntheticDefaultImports": true,
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Expected behavior Setup instructions on how to setup dayjs once globally and have it recognize all used plugin types globally in next 14.
Information
- Day.js Version : 1.11.13
Bump. Same issue in client components.
Having same issue in client components.
Same, doesnt work in client components
same, any update?