Basic Setup

To start using NotCMS, you need to initialize a client with your schema and credentials:
import { Client } from 'notcms';
import { schema } from './notcms/schema';

const nc = new Client({
  schema,
  apiKey: process.env.NOTCMS_SECRET_KEY,
  workspaceId: process.env.NOTCMS_WORKSPACE_ID
});

Prerequisites

Before initializing the client, ensure you have:
  1. Generated schema - Run npx notcms-kit init to generate for the first time or npx notcms-kit pull to update your schema
  2. Environment variables - Set up your API credentials
  3. Installed NotCMS - Add notcms to your project dependencies

Environment Variables

Required Variables

NOTCMS_SECRET_KEY=your-secret-key
NOTCMS_WORKSPACE_ID=your-workspace-id

Loading Environment Variables

// Next.js loads .env automatically
import { Client } from 'notcms';

Framework-Specific Setup

Next.js App Router

// app/lib/notcms.ts
import { Client } from 'notcms';
import { schema } from '@/notcms/schema';

// Server-only client
export const nc = new Client({
  schema,
  apiKey: process.env.NOTCMS_SECRET_KEY!,
  workspaceId: process.env.NOTCMS_WORKSPACE_ID!
});

Remix

// app/lib/notcms.server.ts
import { Client } from 'notcms';
import { schema } from '~/notcms/schema';

// Mark as server-only with .server.ts extension
export const nc = new Client({
  schema,
  apiKey: process.env.NOTCMS_SECRET_KEY!,
  workspaceId: process.env.NOTCMS_WORKSPACE_ID!
});

SvelteKit

// src/lib/notcms.ts
import { Client } from 'notcms';
import { schema } from '../notcms/schema';
import { 
  NOTCMS_SECRET_KEY, 
  NOTCMS_WORKSPACE_ID 
} from '$env/static/private';

export const nc = new Client({
  schema,
  apiKey: NOTCMS_SECRET_KEY,
  workspaceId: NOTCMS_WORKSPACE_ID
});

Troubleshooting

Common Issues

Next Steps

Once your client is initialized, you can: