Getting Started
Set up the BrandApp SDK in your Next.js project in four steps.
1. Install the SDK
Install the SDK directly from the public npm registry.
terminal
pnpm add @reopt-ai/brandapp-sdk2. Set Environment Variables
Create a .env.local file with your BrandApp credentials.
.env.local
# .env.local
BRANDAPP_CLIENT_ID=your_client_id
BRANDAPP_CLIENT_SECRET=your_client_secret
BRANDAPP_ID=your_brandapp_id
# Optional — SDK 가 자동으로 읽으므로 코드에 baseUrl 을 명시 전달할 필요 없음.
# 비워두면 NODE_ENV 로 자동 결정 (prod: https://brandapp.reopt.ai,
# dev: https://brand.local.reopt.io:3443).
# REOPT_BASE_URL=https://brandapp.reopt.ai
BETTER_AUTH_SECRET=your_auth_secret
BETTER_AUTH_URL=http://localhost:30003. Initialize the SDK
Create a shared SDK instance that can be imported across your server-side code.
lib/sdk.ts
import { createReoptSDK } from "@reopt-ai/brandapp-sdk";
// baseUrl / idBaseUrl 은 생략 — SDK 가 process.env.REOPT_BASE_URL /
// REOPT_ID_BASE_URL 을 자동으로 읽고, env 도 없으면 NODE_ENV 로 fallback.
const sdk = createReoptSDK({
clientId: process.env.BRANDAPP_CLIENT_ID!,
clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
brandappId: process.env.BRANDAPP_ID!,
});
// Access modules
const { eav, ai, files, cms } = sdk;4. Make Your First API Call
Use the SDK modules to interact with your BrandApp data.
app/page.tsx
// List all EAV entities
const entities = await sdk.eav.entities.list();
console.log("Entities:", entities);
// Check AI credits
const credits = await sdk.ai.credits();
console.log("Credits:", credits.balance);
// List files
const result = await sdk.files.list({ limit: 10 });
console.log("Files:", result.data.length);