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
relay init hello-api
cd hello-apiinit 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
relay dev --watchThe 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:
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
relay deployThat 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
- Configuration covers
relay.tomland secrets. - Webhooks pushes events to your own systems.