Skip to main content
Encore is an open-source backend framework for TypeScript (and Go) with type-safe APIs, declarative infrastructure, and built-in observability. You can run Restate service handlers inside an Encore app by exposing them via raw endpoints, which give you direct access to the Node.js request/response objects. This lets you use Encore for your API layer, databases, and infrastructure while Restate handles durable execution.
1

Create an Encore app

Follow the Encore quickstart to install the CLI, then create a new app:
2

Install the Restate SDK

Add the Restate TypeScript SDK to your Encore project:
3

Define your Restate service handlers

Create a Restate service with your handler logic. This is standard Restate code:
order-processor/restate.ts
Each ctx.run() call is journaled by Restate. If the process crashes mid-execution, Restate replays completed steps and resumes where it left off.
4

Expose the handler via an Encore raw endpoint

Create the Encore service and wire the Restate endpoint handler to a raw endpoint.Since Encore’s raw endpoints use Node.js HTTP types while the Restate SDK provides a Fetch API handler, we need a small adapter to bridge between the two:
order-processor/encore.restate.ts
order-processor/api.ts
Encore now serves the Restate handler at /restate/*. The Restate Server will call this endpoint to discover and invoke your handlers.
5

Start Restate Server and Encore

In one terminal, start the Restate Server:
In another terminal, start your Encore app:
6

Register your service with Restate

Tell the Restate Server where to find your handlers:
You should see the discovered OrderProcessor service printed out.
The --use-http1.1 flag is needed because Encore’s raw endpoints serve HTTP/1.1.
7

Invoke your handler

Send a request to Restate Server’s ingress (port 8080), which routes it to your Encore-hosted handler:
You can also invoke the handler from other Encore API endpoints using the Restate client:
order-processor/orders.ts
8

You're running Restate handlers inside Encore!