Skip to content

Deno

This guide walks you through integrating the CreativeEditor SDK (CE.SDK) Engine in a Node.js-compatible environment using Deno, the secure and modern runtime for JavaScript and TypeScript. By the end of this guide, you’ll have a Deno script that loads a scene, modifies it, and exports it as an image—all without a UI.

Who is This Guide For?

This guide is for developers who:

  • Want to programmatically edit and export scenes using CE.SDK in Deno.
  • Prefer a secure and modern runtime with built-in TypeScript and native fetch support.
  • Need to integrate CE.SDK into server-side rendering, automation tools, or cloud functions using Deno.

What You’ll Achieve

  • Install and configure CE.SDK Engine in a Deno project.
  • Load and manipulate design scenes programmatically.
  • Export scenes to PNG images without any UI.

Prerequisites

Before getting started, ensure you have:

  • Deno installed
  • A valid CE.SDK license key (Start a free trial to obtain a license key).
  • Deno v1.28 or later to ensure compatibility with npm packages.

Step 1: Initialize Your Deno Project

Create your project structure:

Terminal window
deno init my_project

Resulting in the following project structure:

my_project
├── deno.json
├── main_test.ts
└── main.ts

Step 2: Use CE.SDK Engine via NPM Compatibility

In your main.ts, use Deno’s npm compatibility to load CE.SDK:

// @deno-types="npm:@cesdk/node"
import CreativeEngine from 'npm:@cesdk/node';
import { writeFile } from 'node:fs/promises';
// Fix for TypeScript type resolution in Deno
const { MimeType } = CreativeEngine as any;
// CE.SDK configuration
const config = {
license: 'YOUR_LICENSE_KEY', // Replace with a valid license key
baseURL: 'https://cdn.img.ly/packages/imgly/cesdk-node/1.51.0/assets',
};
CreativeEngine.init(config).then(async engine => {
console.log('CE.SDK Engine initialized (Deno)');
try {
await engine.addDefaultAssetSources();
await engine.scene.loadFromURL(
'https://cdn.img.ly/assets/demo/v1/ly.img.template/templates/cesdk_instagram_photo_1.scene',
);
const [page] = engine.block.findByType('page');
const blob = await engine.block.export(page, MimeType.Png);
const arrayBuffer = await blob.arrayBuffer();
await writeFile('./example-output.png', Buffer.from(arrayBuffer));
console.log('Export completed: example-output.png');
} catch (err) {
console.error('Error:', err);
} finally {
engine.dispose();
}
});

Step 3: Run the Script

Execute the script using Deno’s Node/NPM compatibility adding the following flags:

Terminal window
deno run \
--allow-read \
--allow-write \
--allow-net \
--unstable-ffi \
main.ts

These flags are required to execute main.ts:

FlagRequiredWhy It’s Needed for CE.SDK Engine
--allow-readYesGrants permission to read from the file system. Useful if the engine loads local assets or template files.
--allow-writeYesAllows CE.SDK to write the exported image file (example-output.png) to disk.
--allow-netYesRequired to fetch remote assets and scenes (e.g., from cdn.img.ly).
--unstable-ffiYesEnables WebAssembly FFI, which CE.SDK Engine depends on for core rendering and export features.

Troubleshooting & Common Errors

❌ Error: Cannot find module '@cesdk/node'

  • Make sure you’re running with the -unstable flag and Deno v1.28 or later.
  • Add deno.json or import_map.json if managing multiple npm dependencies.

❌ Error: Invalid license key

  • Ensure your license key is correct and not expired.

❌ TypeScript errors for MimeType

  • Use CreativeEngine as any or assert type manually to bypass missing type declarations.

Next Steps

You’ve successfully integrated CE.SDK Engine in Deno. Now explore: