Getting started · § 1.3

1.3Quickstart

From nothing to a deployed API endpoint in about a minute.

This walkthrough creates a project, runs it locally, and deploys it. It takes about a minute, most of which is typing.

1. Create a project

bash
relay init hello-api
cd hello-api

init scaffolds a relay.toml and one example route. Use relay init --template to pick a REST, GraphQL, or cron starter instead.

2. Run it locally

bash
relay dev --watch

The dev server prints a local URL and a public tunnel URL. Watch mode reloads routes on save, and pressing r replays the last request.

3. Add a route

Create routes/greet.ts:

ts
export default function handler(req: Request) {
  const name = new URL(req.url).searchParams.get('name') ?? 'world';
  return Response.json({ greeting: `Hello, ${name}!` });
}

Save the file, then hit http://localhost:8787/greet?name=Relay.

4. Deploy

bash
relay deploy

That is the whole flow. The deploy output prints your production URL. If anything looks wrong, relay rollback repoints traffic to the previous build in about a second.

Next steps