Skip to main content

@temporalio/create

NPM

Sets up a new Temporal project with a preset skeleton.

Make sure to follow the getting started instructions.

Usage#

npm init @temporalio /path/to/project [--use-yarn] [--temporal-version TEMPORAL_VERSION] [--sample hello-world|hello-world-mtls]

Flags#

  • --use-yarn - configure the project with yarn (defaults to npm).
  • --temporal-version - use specified SDK version or @latest if not provided.

Project Structure#

The generated project consists of 4 sub-projects with typescript project references.

src/worker/ -> Worker code
src/interfaces/ -> Workflow interfaces
src/workflows/ -> Workflow implementations
src/activities/ -> Activity implementations

This code structure is required for enabling Workflows - which run in an isolated environment - to specify a custom tsconfig.json than the rest of the project.

References#

Working with the created project#

The created project comes with some helper package scripts.

  • npm run build - Compile Typescript
  • npm run build.watch - Watch files and compile on change

Running the example#

  • Compile the project with one of the commands above
  • Download, install, and run the Temporal server via docker-compose
  • Start the worker using npm start, or equivalently, node lib/worker
  • In a new terminal, use the provided client to start a Workflow node lib/worker/schedule-workflow.js

Get notified of updates