Skip to main content

Quickstart

This guide takes you through your first steps with Restate.

Prerequisites​

Step 1: Scaffold the project​

Scaffold the project to create your first service:

Use the Node template to get started. This template includes a skeleton of a TypeScript Restate service:

npx -y @restatedev/create-app@latest && cd restate-node-template

Get all the dependencies and build tools:

npm install

Step 2: Build and run the service​

Now, you are all set to start developing your service in src/app.ts. You can run the app with ts-node-dev while developing:

npm run app-dev

Once you have implemented your service, build the app and run it:

npm run build
npm run app

This starts the greeter service on port 9080.

Step 3: Launch the Restate runtime​

Run the Restate Docker container:

docker run --name restate_dev --rm -p 8080:8080 -p 9070:9070 -p 9071:9071 --add-host=host.docker.internal:host-gateway docker.io/restatedev/restate:0.8
tip

Restate is a single self-contained binary and Docker just one of the ways to run it. Check out our download page for how to install the binary via Homebrew and npm.

Register the service:

Now, we need to tell Restate where the service is running.

We can do this via the CLI:

restate dp add http://host.docker.internal:9080

Or via curl, by sending a request to the endpoint of the runtime at http://localhost:9070/deployments and providing it with the deployment endpoint of the service http://host.docker.internal:9080.

curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:9080"}'

Restate then sends a request to the service deployment to ask which services and methods are running behind this deployment and will keep track of these (including of the method signatures). After executing this curl request, you should see the discovered services and methods printed to your terminal.

Step 4: Send requests to the service​

Invoke the function via:

curl localhost:8080/myservice/hello -H 'content-type: application/json' -d '{"request": "Restate"}'

Congratulations, you managed to run your first Restate service.

Next steps​

Possible next steps: