Building Temporal applications with the TypeScript SDK

A planning and build guide for teams writing Temporal workflows in TypeScript and Node.js, covering the workflow sandbox, bundling, activities, worker deployment and the limits to confirm.

On this page

When a TypeScript team should build on the Temporal TypeScript SDK

The Temporal TypeScript SDK lets a Node.js team write long-running business processes as ordinary TypeScript functions that keep their state through restarts, retries, worker crashes and deploys. Workflow code is plain TypeScript, but it runs inside a deterministic sandbox that replays recorded event history, so the code must make the same decisions every time it runs. Activities hold the side effects such as calling payment APIs, sending email or writing to a database, and they are retried by the platform on their own schedule. Workers, which are Node.js processes you deploy, host both the workflow bundle and the activity implementations and poll task queues for work.

Choose Temporal when a process spans minutes, days or months, waits on people or external systems, and must not lose its place when something fails. A queue with a retry policy handles independent jobs well, and cron handles fixed schedules, but both push state handling, timeouts, compensation and visibility back onto your team. If your process needs a human approval step that can take a week, or a saga that must undo earlier steps after a later failure, a workflow model usually fits better. The SDK is one of several official Temporal SDKs, alongside Go, Java, Python, .NET, Ruby and PHP, so the decision should weigh your existing stack and team skills as much as the TypeScript fit. Confirm the current SDK release, its supported Node.js versions and its known limitations in the Temporal documentation before you commit, because the SDK changes more often than the server model.

How a TypeScript workflow moves from client to worker

The walk-through starts in a Node.js client that asks the Temporal Service to start a workflow. The frontend hands the start request to history, which records the event, and matching places a workflow task on a task queue. A TypeScript worker polls that queue, runs the workflow code inside the deterministic sandbox, and schedules activity tasks back through the queue. Activities are the only steps that cross the trust boundary to external systems, so check which side of the boundary each call crosses and what credentials the worker holds on the other side.

Client, Temporal Service, worker, sandbox and external systems, with the trust boundary marked.

Which TypeScript code belongs in workflows, activities, clients and workers

Workflow code describes the business process: the order of steps, branching, waiting on timers and handling signals. The Temporal TypeScript SDK runs it in a deterministic workflow sandbox, and the server replays its recorded history whenever a worker resumes an execution, so the code must produce the same decisions on every replay.

  • Allowed logic: control flow, calls to activities through the workflow API, timers, signal and query handlers, and pure computation on the workflow's inputs.
  • Forbidden operations: direct network calls, file system access, reading the wall clock or environment variables that can change between runs, and random values from unseeded sources.
  • Packaging: workflow files are exported from a module that the worker bundles at startup, so workflow code ships as its own bundle separate from activity code.
  • Change control: edits that alter the command sequence of running executions need a versioning or patching approach, and the exact procedure should be confirmed in the SDK reference and Temporal's versioning documentation.

Before release, confirm that the workflow module and everything it imports perform no I/O and that the bundling step succeeds in your build pipeline.

How to set up a TypeScript Temporal project

This sequence takes a team from an empty directory to a working Temporal application, with a workflow, its activities, a running worker and a completed run visible in the Web UI. Each step ends with a check that proves the piece works before the next one depends on it.

  1. Confirm the Node.js runtime and SDK release

    Before installing anything, check the current Temporal TypeScript SDK documentation for the Node.js version the chosen SDK release supports, and confirm the exact npm package names for the client, worker and workflow-related packages. Pin the Node.js version in your project so every developer and CI job runs the same runtime. You are done when node --version reports a version that matches the SDK documentation and your team has recorded the pinned SDK release.

  2. Install the SDK packages into the project

    Create the project directory, initialize the package manifest, and install the SDK packages named in the documentation as dependencies, along with TypeScript and its Node.js type definitions as development dependencies. Commit the lockfile so the SDK version is fixed across machines. You are done when the install completes without peer dependency errors and the packages appear with the pinned versions in the manifest and lockfile.

  3. Create a shared types module for contracts

    Add a single module that defines the input and output types for each workflow and the argument and return types for each activity. Both the workflow code and the activity code import from this module, so a signature change is caught by the compiler in both places rather than at runtime. Keep this module free of Node.js-specific imports so the workflow sandbox can load it. You are done when the project compiles with the contracts imported from one location.

  4. Write a workflow and its activities

    Write one workflow function that calls one or two activities through the proxy created for activities, with explicit start-to-close timeouts and a retry policy. Put the activity implementations in a separate module that the worker loads, and keep all I/O, clocks and random values inside activities, because workflow code must be deterministic. You are done when the TypeScript build passes and a reviewer can point to every side effect and confirm it sits in an activity.

  5. Start a local Temporal development server

    Start a local development server using the Temporal CLI as described in the current Temporal documentation, which exposes the frontend port and the Web UI on your workstation. This setup uses an in-memory or SQLite-style store and is meant only for development, so do not reuse it for shared or production environments. You are done when the Web UI loads in a browser and the default namespace is listed.

  6. Run a worker that polls a task queue

    Write a small worker script that bundles the workflow code, registers the activity implementations, and polls a named task queue on the local server. Start it and watch its log output for a line confirming it connected and is polling. You are done when the worker stays running, shows no connection errors, and the task queue appears with an active poller in the Web UI.

  7. Start a workflow from a client

    Write a client script that connects to the server, starts the workflow on the same task queue with a unique workflow ID, and waits for the result. Run it once and print the result to the console. You are done when the client prints the expected output and the worker log shows the activity running.

  8. Confirm the run and its history in the Web UI

    Open the workflow in the Web UI, check that its status is completed, and review the event history to confirm each activity was scheduled, started and completed in order. Then restart the worker mid-run in a test workflow and confirm the workflow resumes from its history rather than starting over. You are done when the history matches what the code should do and the team can explain each event in the list.

Worker bundling and deployment options and when each fits

This table compares the four ways TypeScript workflow code and workers are packaged and run, with the fit, operating cost and upgrade effect on running workflows for each. Read it to pick a packaging model, then check the server deployment choice separately, since the two are independent decisions.

OptionBest fitOperational costEffect on running workflows
Prebuilt workflow bundleTeams that want a fixed, reviewed workflow artifact loaded by workers at startBuild step in CI that produces a bundle file, plus a version check before each releaseRunning executions keep their recorded history; new code applies through versioning or patching, so bundle changes must be replayed against existing histories first
Bundling at worker startupSmall teams with one worker codebase and a simple release processEach worker bundles on boot, so startup is slower and bundling output can differ between hosts if dependencies driftRestarting workers picks up new workflow code immediately, so non-deterministic changes can break in-flight executions without a replay check
Container image per serviceTeams with several worker services and a standard Kubernetes or container release pathImage builds, registry storage and per-service pipelines; image tags must map to the workflow code versionRolling out a new image replaces workers gradually, so old and new code overlap during the rollout and versioning must cover both
Long-running worker pool on Kubernetes or virtual machinesOrganizations with existing host management and steady workflow load that needs tuningHost or cluster capacity, patching and worker process supervision, plus monitoring of task queue backlogPool updates follow the same overlap pattern as images, so drain workers on shutdown and confirm in-flight tasks finish before replacing a pool
Temporal Server deployment (separate choice)Decides where the Temporal Service runs, for example Docker Compose, binaries, Helm or a custom Go buildIndependent from worker packaging; self-hosted and Temporal Cloud both accept SDK workersServer upgrades follow their own rules and do not by themselves change how TypeScript workflow code is bundled

How bundling and versioning change what a deployment can break

Changing workflow code while executions are open can break replay, so before the first rollout the team must decide how old and new workflow code will coexist. A Temporal workflow is rebuilt from its recorded event history each time a worker resumes it. If the new bundle issues commands in a different order or with different arguments than the history recorded, the worker fails the workflow task with a non-determinism error. Deployment mechanics decide whether that happens: the bundle a worker loads determines the code that replays every open execution it picks up.

In a TypeScript deployment, the workflow code is bundled by the SDK's worker into a single artifact that is loaded when the worker starts. That bundle, the activity implementations in the same worker image, and the container image tag are versioned together only if the team makes them so. A common failure is a mutable tag such as latest or a rebuilt tag reused for a new bundle, so that pods restarted during a rolling update load different workflow code than the pods that started the executions. Confirm in your pipeline that every build produces an immutable image tag and that the workflowsPath bundle is built from the same commit as the image that serves it.

Keep old workers serving until every open execution started on them has completed, or has been deliberately patched or reset, rather than replacing the whole fleet at once. Drain strategy, the grace period given to in-flight tasks, and the autoscaler's ability to scale the old deployment down all sit in your deployment configuration and should be tested in a non-production namespace. The SDK provides versioning and patching mechanisms for changing workflow logic safely. How to use them, and how to prove a change is compatible with recorded histories, is covered in the replay testing and versioning guidance, so this section only addresses what the rollout itself can break.

Which determinism rules the TypeScript sandbox enforces and where teams still break them

The TypeScript workflow sandbox replaces some nondeterministic sources with deterministic ones, but it cannot stop every pattern. Each card below names a class of nondeterminism, the mistake that usually introduces it, and the safe pattern to use instead, so that replay on a worker produces the same commands as the original run.

Current time and random values

Workflow code that reads the wall clock or generates random values gets different answers on each replay, so the commands it issues no longer match the recorded history. The typical mistake is calling Date.now(), new Date() or Math.random() directly in workflow logic for timeouts or identifiers. The safe pattern is to use the SDK-provided workflow clock and the deterministic random helpers, and to generate IDs in an activity when the value must be stored outside the workflow. Check every timeout and branch in the workflow file for raw time calls, and confirm the sandbox behavior for your SDK version.

Deployment docs

Network and file access

Workflow code must not open sockets, call HTTP APIs, or read and write files, because those results can differ between the original execution and a replay. The typical mistake is adding a quick fetch or file read inside the workflow function to get a value that seems stable. The safe pattern is to move every external call into an activity, which Temporal records and retries, and pass the result back into the workflow as an input or return value. Review imports and helper functions called from workflows, since a call buried in a shared utility is easy to miss in code review.

Reading environment state

Reading process.env, feature flags, or configuration files from inside a workflow means the value on replay may not match the value on the first run after a deployment changes it. The typical mistake is checking an environment variable to choose between two code paths in workflow logic. The safe pattern is to read configuration in the client or in an activity, then pass the chosen values into the workflow as explicit input so the history records them. Confirm that any flag that changes workflow branching is versioned or passed as data, because a rollout that flips the flag mid-execution can cause a non-determinism error during replay.

Unordered iteration that affects commands

Iterating over a Set, Map, or object keys is ordered by insertion in JavaScript, but the order can change when the code that builds the collection changes, and a different order produces different commands. The typical mistake is starting one activity per entry of an object built from concurrent results, then relying on the completion order to decide the next step. The safe pattern is to sort keys explicitly before iterating, to build arrays from stable inputs, and to collect results with Promise.all in a fixed order. Replay tests with real histories will catch command-order changes that unit tests with small inputs miss.

Node.js modules the sandbox does not allow

The workflow sandbox runs workflow code in an isolated environment without Node.js built-ins such as fs, net, or crypto for nondeterministic work, so importing them fails or produces values that differ across runs. The typical mistake is importing a helper library that pulls in a built-in module, which works in tests running outside the sandbox and then fails when the worker bundles the workflow. The safe pattern is to keep workflow files limited to pure logic and types, to put Node.js code in activities, and to keep the workflow bundle small. Confirm the documented pass-through and allowed-module behavior for your SDK version before adding a dependency to a workflow file.

How to secure TypeScript workers and the Temporal Service they connect to

Start from the fact that a self-hosted Temporal Service accepts every API request until you configure access control. If no Authorizer is set, the server uses the default noopAuthorizer, which allows all requests with no authentication. Before a TypeScript worker or client connects to a shared environment, decide how it will prove its identity. The documented options are mutual TLS with separate settings for internode and frontend traffic, a ClaimMapper that maps JWT or certificate claims to namespace roles, and an Authorizer plugin that makes the allow or deny decision. Give each worker identity only the namespace access its task queues need, and confirm the exact configuration keys and claim formats for your Temporal Server version in the Temporal self-hosted security documentation before you write the worker's Connection and TLS options.

Network placement is the second control. The Temporal deployment documentation says Temporal services should run on hosts that are not reachable from the public internet, with access restricted to trusted internal networks. Your TypeScript workers should reach the frontend over a private path, and the Web UI should sit behind OIDC single sign-on rather than an open port. Payload encryption is the third control, and it changes how you write code. Workflow history stores the inputs and results that your workflows and activities pass around. If you encrypt those payloads with a custom codec, the codec must be installed in the TypeScript client and worker data converter, and a codec server must be configured so the Web UI can decode history for authorized users. Plan the key lifecycle and test that a worker with the wrong key fails loudly, not silently.

Secrets used by activities, such as API tokens, database passwords and signing keys, should never be placed in workflow inputs, which are recorded in history. Keep them in a secrets manager that your team controls, and let activity code fetch them at run time under the worker's own identity. Confirm which secrets manager, rotation process and audit logging your organization requires before the first activity is written. For the detailed control set, including how these settings map to specific regulatory requirements, see the Temporal security and Temporal compliance pages in this series.

Limits and questions to confirm before committing to the TypeScript SDK

The TypeScript SDK sits on top of a Temporal Service whose version, storage and namespace limits you control or contract for. Each item below is a question to settle in your own environment before you commit code, and each should be confirmed against the current SDK and Temporal documentation rather than assumed.

Node.js and SDK compatibility

Confirm which Node.js versions and which @temporalio SDK release your Temporal Server version supports. The server upgrade path has its own rules, so an SDK chosen today may not match the server you run in six months. Ask whether your Node.js LTS line is on the SDK's supported list, and record the pairing in your build pipeline so workers and the server are changed in a planned order.

Server upgrade docs

Persistence store support

Check that your chosen persistence database is on Temporal's tested list. Persistence is tested on Cassandra, PostgreSQL and MySQL, and SQLite is meant only for development and testing. Confirm the exact versions for your Temporal Server release, because a supported engine version can differ from the one your database team runs. Treat SQLite as a local development choice, not a production option.

Persistence docs

Visibility store choice

Confirm that your visibility store matches the server version and your expected volume. Visibility queries power search and listing in the Web UI and in your own code. Cassandra visibility was removed in 1.24, and Elasticsearch or OpenSearch is recommended for anything beyond a few workflow executions. Verify the supported versions before you design queries around search attributes.

Visibility docs

Payload size and history growth

Long-running workflows accumulate event history, and large inputs or results add to every event. Estimate payload sizes for your activities and signals, and check the size and history limits that apply to your server or Temporal Cloud namespace. Plan for Continue-As-New or child workflows where histories grow without bound. Ask your team to measure real payloads in a staging environment before setting batch sizes.

Library compatibility with the sandbox

Workflow code runs in a deterministic sandbox, so npm packages that use I/O, timers, randomness or Node.js built-ins may fail or behave differently inside it. Test each library you plan to import into workflow code, and keep network and database calls inside activities. Record which packages are approved for workflow code and which must stay in activity modules.

Namespace and service limits

Confirm whether your self-hosted Temporal Service or Temporal Cloud namespace provides the rate limits, retention period, worker connection count and feature set you need. Ask Temporal or your platform team for the documented values for your plan, and check them against your planned throughput. Put the answers in the design record, because a limit found in production is costly to change.

Temporal pricing

Questions teams ask before building with the TypeScript SDK

What does building a first Temporal workflow in TypeScript cost?

The cost is mostly engineering time, and it depends on how many workflows and activities the first release needs, how many external systems each activity calls, and how much review the design needs. The main components are design work on workflow boundaries and retries, implementation of workflows and activities, the worker and deployment setup, and a determinism review of workflow code before it runs in production. Hosting cost is separate: a self-hosted Temporal Service carries infrastructure and database costs, while Temporal Cloud bills on usage. Ask for a written scope that lists each workflow, each integration, the review steps and the hosting model, then compare quotes against that same list.

How long does a Temporal TypeScript pilot take?

Pilot length depends on scope, not on the SDK alone. The main drivers are the number of workflows, how many integrations need working activities, whether the Temporal Service is already running or still needs to be built, and how long your security and hosting reviews take. Delays often come from waiting on access to systems, sign-off on data handling, and decisions about versioning and retries that the team has not made yet. Ask for a timeline tied to written deliverables and name the client-side dependencies in that plan, so both sides know which steps wait on your team.

What does our team need to provide for a TypeScript Temporal build?

The build needs a few things from your side before it starts:

  • Node.js and cloud access in the environments where workers will run, plus repository and CI access.
  • A Temporal Service you operate, or a Temporal Cloud namespace, with the connection details the workers need.
  • A named owner for each activity, since activities call your systems and someone must confirm their behavior, credentials and data.
  • A named owner for the data each workflow carries and for its retention.
  • Reviewers with time booked for design reviews, determinism checks and security sign-off.

Confirm these owners and review slots in writing at the start, because they often set the pace more than the code does.

Can an in-house team build Temporal applications in TypeScript alone?

Yes, a capable TypeScript team can build Temporal applications in-house, provided it has time to learn the programming model and someone accountable for the design. The hard parts are less about syntax and more about workflow determinism, versioning changes to running workflows, activity idempotency, worker sizing and safe deployment. Teams with no prior Temporal experience often benefit from an outside review of the first workflows before they grow. DeployOpen can plan, build and review the work with your team, and the split of responsibility should be written into the scope so your engineers know what they own after handover.

Does Temporal Cloud pricing change the cost of a TypeScript build?

Temporal Cloud changes the hosting line of the budget, not the build itself. Its pay-as-you-go pricing, published on the Temporal pricing page, starts at 50 US dollars per million actions, with active storage at 0.042 dollars per GB-hour and retained storage at 0.00105 dollars per GB-hour. Quotes depend on your usage, so estimate actions and storage from your expected workflow volume before comparing it with a self-hosted Temporal Service. Support tiers and SLA levels are priced separately, so ask for them in the quote. The build work for workflows, activities and workers stays largely the same either way.

What breaks most often in a first TypeScript Temporal workflow?

The most common problems are workflow code that is not deterministic, activities without idempotency, and retry settings that do not match the external system. Workflow code runs in a sandbox that restricts some APIs, and changes to running workflows can cause non-determinism errors if they are not versioned. Other frequent issues include oversized payloads, workers that cannot keep up with task queues, and secrets passed through workflow inputs. Build replay tests and a review checklist into the first release, and confirm with your security team how workflow data is stored and who can read it.

What should a written scope include before we get a quote?

A useful written scope lists the workflows and activities in the first release, each external system they call, the hosting model (self-hosted or Temporal Cloud), the security and identity requirements, the test and replay approach, and the deployment target for workers. It should name the deliverables, such as source code, runbooks and review notes, and the client-side responsibilities described above. Ask for the assumptions behind each cost and timeline line so you can see what would change the price. DeployOpen works from a written scope agreed before work starts, so a quote can be checked against it.

How DeployOpen scopes, builds and supports Temporal TypeScript applications

DeployOpen approaches Temporal TypeScript work as a written, fixed-scope engagement inside infrastructure you control. We agree on the workflows, activities, workers and deployment target before build starts, then hand over code, configuration and documentation your team can run and change.

How we scope

  • Inventory the business processes that need durable workflows, with their retries, timeouts and human steps.
  • Define which Temporal services, namespaces and task queues the TypeScript application will use.
  • Agree in writing whether the server runs self-hosted or on Temporal Cloud, with deliverables and timelines.

How we build

  • Write deterministic workflow code that runs inside the TypeScript workflow sandbox, with activities kept outside it.
  • Configure bundling of workflow code and worker deployment on your Node.js runtime and container platform.
  • Test workflows with the time-skipping test server and replay tests against recorded event histories before release.

How we hand over

  • Deliver source code, worker images, deployment manifests and versioning rules for changing workflow code safely.
  • Document the workflow catalog, task queue layout, timeout settings and runbooks for failed executions.
  • Walk your engineers through running, upgrading and testing the workers, and confirm access to the code repository.

How we support

  • Offer ongoing support, worker upgrades and continuous testing as a retainer after handover.
  • Review workflow changes for non-determinism and versioning impact before they reach production.
  • Confirm with your platform team the Temporal Server upgrade path and the support level your environment needs.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.