기능 토글
config.ts의 features 객체로 기능을 켜고 끄는 방법을 설명합니다.
개요
kindie의 핵심 설계 원칙은 필요한 기능만 켜서 쓰는 것입니다. config.ts의 features 객체에서 불필요한 기능을 false로 설정하면, 해당 기능에 필요한 환경변수를 설정하지 않아도 에러 없이 동작합니다.
features 객체
// config.ts
export const features = {
auth: {
credentials: true, // 이메일/비밀번호 로그인
kakao: true, // 카카오 OAuth
naver: true, // 네이버 OAuth
google: true, // Google OAuth
},
payment: true, // PortOne 결제
sms: true, // Solapi SMS 인증
email: true, // Resend 이메일
addressSearch: true, // JUSO 주소검색
} as const;동작 원리
config.ts (features)
↓
lib/integrations.ts (features + 환경변수 검증)
↓
각 모듈 (integrations 결과에 따라 조건부 실행)lib/integrations.ts는 features 플래그와 환경변수를 동시에 확인합니다:
// lib/integrations.ts
export const integrations = {
oauth: {
kakao:
features.auth.kakao &&
hasValue(process.env.AUTH_KAKAO_ID) &&
hasValue(process.env.AUTH_KAKAO_SECRET),
// ...
},
payments:
features.payment &&
hasValue(process.env.NEXT_PUBLIC_PORTONE_STORE_ID) &&
hasValue(process.env.NEXT_PUBLIC_PORTONE_CHANNEL_KEY) &&
hasValue(process.env.PORTONE_API_SECRET),
// ...
};따라서 기능을 비활성화하려면 두 가지 방법 중 하나를 사용하면 됩니다:
config.ts에서false로 설정 (권장)- 해당 환경변수를 비우기
실전 시나리오
카카오 로그인만 끄기
// config.ts
export const features = {
auth: {
credentials: true,
kakao: false, // ← 이것만 변경
naver: true,
google: true,
},
// ...
};카카오 로그인 버튼이 UI에서 사라지고, 카카오 OAuth 프로바이더가 인증 설정에서 제외됩니다.
결제 없이 시작하기
export const features = {
// ...
payment: false, // ← 결제 비활성화
// ...
};결제 관련 환경변수(PortOne)를 설정하지 않아도 에러가 발생하지 않습니다. 결제 API/서버 액션은 자동으로 비활성화됩니다.
최소 설정으로 시작하기
이메일/비밀번호 로그인만으로 시작하고 싶다면:
export const features = {
auth: {
credentials: true,
kakao: false,
naver: false,
google: false,
},
payment: false,
sms: false,
email: false,
addressSearch: false,
};이 경우 필요한 환경변수는 DATABASE_URL과 AUTH_SECRET뿐입니다.