Getting started

Installation

Install the SDK and set the required environment variables.

Install the Elmapi JavaScript SDK from npm:

npm install @elmapicms/js-sdk

Environment variables

Create a .env.local file (or your host's env settings) with:

ELMAPI_BASE_URL=https://your-instance.example/api
ELMAPI_PROJECT_ID=your-project-uuid
ELMAPI_API_KEY=your-project-api-token

Keep ELMAPI_API_KEY on the server only. Do not prefix it with NEXT_PUBLIC_.

Create a client

import { createClient } from '@elmapicms/js-sdk';
 
export const elmapi = createClient({
  baseUrl: process.env.ELMAPI_BASE_URL!,
  projectId: process.env.ELMAPI_PROJECT_ID!,
  apiKey: process.env.ELMAPI_API_KEY!,
});

Verify connectivity

List collections or a known singleton (for example site-settings) and confirm you receive published fields. If the call fails, check the base URL, project UUID, and token abilities.