Search Docs
Loading...
Skip to content

Save

Save and serialize designs in CE.SDK for later retrieval, sharing, or storage using string or archive formats.

8 mins
estimated time
Download
StackBlitz
GitHub

CE.SDK provides two formats for persisting designs. Choose the format based on your storage and portability requirements.

Save Format Comparison#

Format Method Assets Best For
String saveToString() Referenced by URL Database storage, cloud sync
Archive saveToArchive() Embedded in ZIP Offline use, file sharing

String format produces a lightweight Base64-encoded string where assets remain as URL references. Use this when asset URLs will remain accessible.

Archive format creates a self-contained ZIP with all assets embedded. Use this for portable designs that work offline.

Save to String#

Serialize the current scene to a Base64-encoded string suitable for database storage.

const sceneString = await engine.scene.saveToString();

The string contains the complete scene structure but references assets by their original URLs.

Save to Archive#

Create a self-contained ZIP file with the scene and all embedded assets.

const archiveBlob = await engine.scene.saveToArchive();

The archive includes all pages, elements, and asset data in a single portable file.

Compression Options (Preview)#

CE.SDK supports optional compression for saved scenes to reduce file size. Compression is particularly useful for large scenes or when storage space is limited.

import { CompressionFormat, CompressionLevel } from '@cesdk/node';
// Save with Zstd compression (recommended)
const compressed = await engine.scene.saveToString(
undefined, // allowedResourceSchemes
undefined, // onDisallowedResourceScheme
CompressionFormat.Zstd, // compression format
CompressionLevel.Default // compression level
);

Compression Formats:

  • CompressionFormat.None - No compression (default)
  • CompressionFormat.Zstd - Zstandard compression (recommended for best performance)

Compression Levels:

  • CompressionLevel.Fastest - Fastest compression, larger output
  • CompressionLevel.Default - Balanced speed and size (recommended)
  • CompressionLevel.Best - Best compression, slower

Performance: Compression adds minimal overhead (<50ms) while reducing scene size by approximately 64%. The Default level provides the best balance of speed and compression ratio.

Availability:

  • Browser (Web): Available in current release via @cesdk/cesdk-js
  • Node.js: Available in development builds. Use npm run dev:local in examples to test with local build, or wait for the next package release
  • iOS/Android: Planned for future releases

Write to File System#

Use Node.js writeFileSync to persist saved designs to the file system.

Scene strings can be written directly as text:

writeFileSync(`${outputDir}/scene.scene`, sceneString);

For archives, convert the Blob to a Buffer before writing:

const archiveBuffer = Buffer.from(await archiveBlob.arrayBuffer());
writeFileSync(`${outputDir}/scene.zip`, archiveBuffer);

Load Scene from File#

Read a previously saved .scene file from disk and restore it to the engine.

const sceneString = readFileSync(`${outputDir}/scene.scene`, 'utf-8');
await engine.scene.loadFromString(sceneString);

Scene files are lightweight but require the original asset URLs to remain accessible.

Load Archive from File#

Read a self-contained .zip archive from disk with all embedded assets.

const archivePath = path.resolve(`${outputDir}/scene.zip`);
const archiveFileUrl = `file://${archivePath}`;
await engine.scene.loadFromArchiveURL(archiveFileUrl);

Archives are portable and work offline since all assets are bundled within the file.

API Reference#

Method Description
engine.scene.saveToString() Serialize scene to Base64 string
engine.scene.saveToArchive() Save scene with assets as ZIP blob
engine.scene.loadFromString() Load scene from serialized string
engine.scene.loadFromURL() Load scene from remote URL
engine.scene.loadFromArchiveURL() Load scene from URL (file://, http://, https://, or object URL)

Next Steps#