Skip to content

The SDK

The StudioCMS SDK is a powerful tool that allows you to interact with StudioCMS programmatically. It provides a set of functions and utilities that allow you to manage and serve your content using our own in-house Kysely^ database client. It also provides the backbone for the StudioCMS Dashboard, and is built with Effect^.

The StudioCMS SDK is available as a virtual module in your Astro project. You can import and utilize it using the following syntax:

example.ts
/// <reference types="studiocms/v/types" />
// ---cut---
import { SDKCore, SDKCoreJs, runSDK } from 'studiocms:sdk';
import { Effect } from 'studiocms/effect';
// Create the Usable Effect
const pagesEffect = Effect.gen(function* () {
const sdk = yield* SDKCore;
// then do something with the SDK
return yield* sdk.GET.pages()
});
// Convert the Effect into a JS/TS "program"
const pagesResult1 = await runSDK(pagesEffect);
// Just run the SDKCoreJS with the runSDK wrapper!
const pagesResult2 = await runSDK(SDKCoreJs.GET.pages());

The following is a list of the Primary utils provided by the StudioCMS SDK for interacting with the database.

utils.ts
/// <reference types="studiocms/v/types" />
// ---cut---
import { SDKCoreJs } from 'studiocms:sdk';
const {
dbService,
cache,
AUTH,
CLEAR,
CONFIG,
DELETE,
diffTracking,
GET,
INIT,
MIDDLEWARES,
notificationSettings,
PLUGINS,
POST,
resetTokenBucket,
REST_API,
UPDATE,
UTIL,
} = SDKCoreJs;

The StudioCMS SDK is powered by the @withstudiocms/sdk package, which provides additional functionality and utilities for working with StudioCMS. For more information, check out the Kysely and SDK package documentation.