diff --git a/apps/as/app/layout.tsx b/apps/as/app/layout.tsx index d152e0da3..f08c67ca7 100644 --- a/apps/as/app/layout.tsx +++ b/apps/as/app/layout.tsx @@ -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 ( - + {children} diff --git a/apps/as/package.json b/apps/as/package.json index fb27f8af7..3806f73ee 100644 --- a/apps/as/package.json +++ b/apps/as/package.json @@ -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", diff --git a/apps/as/shared/lib/cookie.ts b/apps/as/shared/lib/cookie.ts new file mode 100644 index 000000000..6557cb81d --- /dev/null +++ b/apps/as/shared/lib/cookie.ts @@ -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); +} diff --git a/apps/as/shared/lib/index.ts b/apps/as/shared/lib/index.ts index 51e9c2c5d..26a6d4551 100644 --- a/apps/as/shared/lib/index.ts +++ b/apps/as/shared/lib/index.ts @@ -1,2 +1,3 @@ export { queryClient } from "./query-client"; export { dayjs } from "./dayjs"; +export { getCookie, setCookie, removeCookie } from "./cookie"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f78691690..569437868 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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)