보조기억장치

zod 사용법 본문

React/Next.js

zod 사용법

캐세이 2024. 4. 30. 23:57

설치

npm i zod

 

(기본 사용법)

main.ts

import { z } from "zod"

 

const UserSchema = z.object({

    username: z.string(),

    age: z.number(),

})

 

type User = z.infer<typeof UserSchema>

 

const user: User = { username : "Jeon" }

 

console.log(UserSchema.parse(user))

 

'React > Next.js' 카테고리의 다른 글

shadcn/ui 다크모드 적용  (0) 2023.10.23
Favicon 추가 하기  (0) 2023.10.23
Next.js 13.5  (0) 2023.09.21
Vercel Module not found: Can't resolve  (0) 2023.09.08
Clerk 적용해보기  (0) 2023.08.07