[as] feat: 쿠키 메서드 생성

This commit is contained in:
2026-02-26 13:56:32 +09:00
parent b34d131c1a
commit 717732aad3
5 changed files with 40 additions and 2 deletions
+9 -2
View File
@@ -1,6 +1,9 @@
import type { Metadata } from "next";
import { cookies } from "next/headers";
import { Noto_Sans_KR } from "next/font/google";
import { Providers } from "./providers";
import { setCookie } from "@/shared/lib";
import { SITE_ID } from "@/shared/config";
import "./globals.css";
const notoSansKR = Noto_Sans_KR({
@@ -19,9 +22,13 @@ interface RootLayoutProps {
children: React.ReactNode;
}
export default function RootLayout({ children }: RootLayoutProps) {
setCookie("site-id-key", SITE_ID);
export default async function RootLayout({ children }: RootLayoutProps) {
const theme = (await cookies()).get("site-theme-key");
return (
<html lang="ko" className={notoSansKR.variable}>
<html lang="ko" className={notoSansKR.variable} data-theme={theme?.value}>
<body className={`${notoSansKR.className} antialiased`}>
<Providers>{children}</Providers>
</body>
+2
View File
@@ -19,11 +19,13 @@
"@tanstack/react-table": "^8.21.2",
"axios": "^1.8.1",
"dayjs": "^1.11.13",
"js-cookie": "^3.0.5",
"next": "15.3.8",
"react-hook-form": "^7.54.2",
"zod": "^3.24.2"
},
"devDependencies": {
"@types/js-cookie": "^3.0.6",
"eslint": "^9.0.0",
"eslint-config-next": "15.4.0",
"postcss": "^8.4.49",
+22
View File
@@ -0,0 +1,22 @@
import Cookies from "js-cookie";
export function getCookie(name: string): string | undefined {
if (typeof window === "undefined") {
return undefined;
}
return Cookies.get(name);
}
export function setCookie(name: string, value: string, options?: Cookies.CookieAttributes): void {
if (typeof window === "undefined") {
return;
}
Cookies.set(name, value, options);
}
export function removeCookie(name: string, options?: Cookies.CookieAttributes): void {
if (typeof window === "undefined") {
return;
}
Cookies.remove(name, options);
}
+1
View File
@@ -1,2 +1,3 @@
export { queryClient } from "./query-client";
export { dayjs } from "./dayjs";
export { getCookie, setCookie, removeCookie } from "./cookie";
+6
View File
@@ -80,6 +80,9 @@ importers:
dayjs:
specifier: ^1.11.13
version: 1.11.19
js-cookie:
specifier: ^3.0.5
version: 3.0.5
next:
specifier: 15.3.8
version: 15.3.8(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
@@ -90,6 +93,9 @@ importers:
specifier: ^3.24.2
version: 3.25.76
devDependencies:
'@types/js-cookie':
specifier: ^3.0.6
version: 3.0.6
eslint:
specifier: ^9.0.0
version: 9.39.2(jiti@1.21.7)