Next.js & TailwindCSS & Shadcn UI & Vercel storage

package.json
{
  "name": "server-action-practice",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.1.1",
    "lucide-react": "^0.379.0",
    "next": "14.2.3",
    "react": "^18",
    "react-dom": "^18",
    "tailwind-merge": "^2.3.0",
    "tailwindcss-animate": "^1.0.7"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "eslint": "^8",
    "eslint-config-next": "14.2.3",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "typescript": "^5"
  }
}


tailwindCSS + prettier

npm install -D prettier prettier-plugin-tailwindcss eslint-confi-prettier

prettier.config.js
module.exports = {
  plugins: ['prettier-plugin-tailwindcss'],
}
.eslintrc.json
{
  "extends": ["next/core-web-vitals", "prettier"]
}

shadcn

component.json과 utils.ts 파일이 만들어진다.

postgres 설정하기

prisma 초기화

vercel postgres storage 생성하기

.env.local 탭에서 환경변수 복사 후 .env파일에 적용

schema.prisma 파일 내 db 코드 수정

model 정의하기

@@map의 역할

테이블 이름 지정

  • Prisma 모델의 이름이 데이터베이스에서 사용할 테이블 이름과 다른 경우 @@map 지시어를 사용하여 특정 데이터베이스 테이블 이름을 지정할 수 있다.

    • Prisma 모델 Job이 데이터베이스에 jobs라는 이름의 테이블로 매핑되어야 한다면 @@map("jobs")를 모델 정의에 추가하여 명시할 수 있다.

  • @@map 지시어 없이도 Prisma는 일반적으로 모델 이름의 복수형을 테이블 이름으로 사용한다. (Job ➡️ jobs) 그러나 테이블 이름이 모델 이름의 단순 복수형이 아닌 경우, 또는 데이터베이스 설계상 특별한 이름 규칙을 따라야 할 때 @@map을 사용하여 명시적으로 테이블 이름을 지정할 수 있다.

추가적인 명확성 제공

  • Prisma 스키마에서 테이블 이름을 명확히 하여, 코드를 읽고 이해하는 사람이 데이터베이스 구조를 더 쉽게 파악할 수 있도록 돕는다.

Prisma DB push & generate

prisma.ts

seed 명령어 추가하기

placeholder-data.js
seed.js

scripts 명령어 추가 후 실행

blob storage 생성하기

postgres storage와 동일하게 생성 후, .env 파일에 환경변수 추가

Last updated