createWorld

Create a new World instance from environment configuration.

Creates a new World instance based on environment configuration. The WORKFLOW_TARGET_WORLD environment variable determines which World implementation is instantiated (for example the local development World or the Vercel production World).

Unlike getWorld(), which caches a singleton instance, createWorld() constructs a fresh instance on every call. Application code should almost always use getWorld()createWorld() is for infrastructure code that manages World lifecycles itself.

import { createWorld } from "workflow/runtime";

const world = await createWorld(); 

API Signature

Parameters

This function does not accept any parameters. Configuration is read from environment variables.

Returns

Returns a newly constructed World instance.

In workflow 4.x, createWorld() is synchronous and returns World directly. It becomes async in 5.x, so writing await createWorld() works on both versions.

Tooling that needs to construct a World with explicit (non-environment) configuration should instantiate the specific World implementation directly and register it with setWorld().

  • getWorld() - Resolve the cached World instance (preferred in application code).
  • setWorld() - Override the cached World instance.

On this page

Edit this page on GitHub