home / skills / encoredev / skills / getting-started

getting-started skill

/encore/getting-started

This skill helps you start an Encore.ts app quickly by guiding installation, setup, and running your first API.

npx playbooks add skill encoredev/skills --skill getting-started

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.7 KB
---
name: encore-getting-started
description: Get started with Encore.ts - create and run your first app.
---

# Getting Started with Encore.ts

## Instructions

### Install Encore CLI

```bash
# macOS
brew install encoredev/tap/encore

# Linux/WSL
curl -L https://encore.dev/install.sh | bash

# Windows (PowerShell)
iwr https://encore.dev/install.ps1 | iex
```

### Create a New App

```bash
# Interactive - choose from templates
encore app create my-app

# Or start with a blank app
encore app create my-app --example=ts/hello-world
```

### Project Structure

A minimal Encore.ts app:

```
my-app/
├── encore.app           # App configuration
├── package.json         # Dependencies
├── tsconfig.json        # TypeScript config
├── encore.service.ts    # Service definition
└── api.ts               # API endpoints
```

### The encore.app File

```cue
// encore.app
{
    "id": "my-app"
}
```

This file marks the root of your Encore app. The `id` is your app's unique identifier.

### Define a Service

Create `encore.service.ts` to define a service:

```typescript
// encore.service.ts
import { Service } from "encore.dev/service";

export default new Service("my-service");
```

### Create Your First API

```typescript
// api.ts
import { api } from "encore.dev/api";

interface HelloResponse {
  message: string;
}

export const hello = api(
  { method: "GET", path: "/hello", expose: true },
  async (): Promise<HelloResponse> => {
    return { message: "Hello, World!" };
  }
);
```

### Run Your App

```bash
# Start the development server
encore run

# Your API is now available at http://localhost:4000
```

### Open the Local Dashboard

```bash
# Opens the local development dashboard
encore run
# Then visit http://localhost:9400
```

The dashboard shows:
- All your services and endpoints
- Request/response logs
- Database queries
- Traces and spans

### Common CLI Commands

| Command | Description |
|---------|-------------|
| `encore run` | Start the local development server |
| `encore test` | Run tests |
| `encore db shell <db>` | Open a psql shell to a database |
| `encore gen client` | Generate API client code |
| `encore app link` | Link to an existing Encore Cloud app |

### Add a Database

```typescript
// db.ts
import { SQLDatabase } from "encore.dev/storage/sqldb";

const db = new SQLDatabase("mydb", {
  migrations: "./migrations",
});
```

Create a migration:

```sql
-- migrations/1_create_table.up.sql
CREATE TABLE items (
    id SERIAL PRIMARY KEY,
    name TEXT NOT NULL
);
```

### Next Steps

- Add more endpoints (see `encore-api` skill)
- Add authentication (see `encore-auth` skill)
- Add infrastructure like Pub/Sub, cron jobs (see `encore-infrastructure` skill)
- Deploy to Encore Cloud: `encore app link` then `git push encore`

Overview

This skill guides you through creating and running your first Encore.ts app. It covers installing the Encore CLI, scaffolding a minimal TypeScript service, adding an API endpoint, and running the local development server and dashboard. Follow it to go from zero to a working local service in minutes.

How this skill works

The skill shows the exact CLI commands to install Encore on macOS, Linux/WSL, and Windows, then demonstrates creating a new app from a template or a blank example. It explains the minimal project layout, how to declare an Encore service and an API endpoint in TypeScript, how to add a SQL database and migration, and how to run the app and open the local dashboard. It also lists common Encore CLI commands and the typical next steps for adding features or deploying.

When to use it

  • You want a quick, reproducible path to a running Encore.ts app.
  • You need a minimal TypeScript service and a sample HTTP endpoint to iterate locally.
  • You plan to add a database and want an example migration and connection setup.
  • You want to learn the core Encore CLI commands and the local dashboard workflow.
  • You’re preparing to deploy to Encore Cloud and need the local development flow first.

Best practices

  • Start with the provided hello-world example to confirm your environment works before adding complexity.
  • Keep encore.app at the project root and use a clear id string to identify the app.
  • Define services in separate files (encore.service.ts) and keep API routes in api.ts for clarity.
  • Commit SQL migrations alongside schema changes and use encore db shell for quick database inspection.
  • Use encore gen client to generate client code when you add or change endpoints.

Example use cases

  • Create a tiny microservice with a GET /hello endpoint for testing routing and telemetry.
  • Prototype a CRUD API backed by a SQLDatabase and a simple migration file.
  • Build a dev-only local dashboard-driven app to inspect traces, logs, and queries during development.
  • Generate client libraries for frontend integration with encore gen client, then iterate on endpoints locally.
  • Link the repo to Encore Cloud and push with git after validating locally with encore run.

FAQ

Where is the app available after running encore run?

The API is typically available at http://localhost:4000 and the local dashboard at http://localhost:9400.

How do I add a database migration?

Create SQL files under migrations (e.g., migrations/1_create_table.up.sql) and configure a SQLDatabase in a db.ts file; migrations are applied via Encore CLI during startup or deploy.