JavaScript client

Installation

Install the framework-neutral JavaScript client.

The framework-neutral client is published as @degallery/sdk. It works in browser, server, and non-React JavaScript applications.

Choose this package when you want typed API access without adopting the React UI. For trusted backend workflows that handle secrets or local files, add @degallery/node as well.

Install the client

pnpm add @degallery/sdk
npm install @degallery/sdk
yarn add @degallery/sdk

For trusted Node.js integrations that need server-only workflows, use @degallery/node:

pnpm add @degallery/node

The Node package re-exports the client types and adds Node-specific helpers. Keep it on the server boundary.

Configure the server environment

Create a server-only environment variable. The API key must not use a NEXT_PUBLIC_ prefix or appear in browser code.

.env.local
DEGALLERY_API_URL=https://api.degallery.mpotulo.com
DEGALLERY_API_KEY=your_server_key

Create a client

import { GalleryClient } from '@degallery/sdk';

export function createGalleryClient() {
  return new GalleryClient({
    apiUrl: process.env.DEGALLERY_API_URL,
    apiKey: process.env.DEGALLERY_API_KEY,
  });
}

Verify the connection

const client = createGalleryClient();
const gallery = await client.getGallery('gallery_id');

console.log(gallery.name, gallery.items.length);

Browser applications

For browser reads, use a publishable key or a short-lived read token issued by your server. Never put a private API key in a client bundle.

Continue

On this page