What is Encore?
Encore is a backend development platform that uses static analysis to understand your application and automatically provision infrastructure. You write TypeScript (or Go) — Encore handles AWS/GCP resources, networking, and observability.
No Terraform. No Docker. No YAML. Just code.
Quick Start
npm install -g encore.dev
encore app create my-app --lang=ts
cd my-app
encore run
Define APIs
// backend/hello/hello.ts
import { api } from "encore.dev/api";
interface HelloResponse {
message: string;
}
export const world = api(
{ method: "GET", path: "/hello/:name", expose: true },
async ({ name }: { name: string }): Promise<HelloResponse> => {
return { message: `Hello ${name}!` };
}
);
Encore generates:
- API documentation
- Request/response validation
- Distributed tracing
- API gateway with auth middleware
Databases (Zero Config)
import { SQLDatabase } from "encore.dev/storage/sqldb";
const db = new SQLDatabase("users", {
migrations: "./migrations",
});
export const getUser = api(
{ method: "GET", path: "/users/:id" },
async ({ id }: { id: string }) => {
const user = await db.queryRow`
SELECT id, name, email FROM users WHERE id = ${id}
`;
return user;
}
);
export const createUser = api(
{ method: "POST", path: "/users" },
async ({ name, email }: { name: string; email: string }) => {
const result = await db.exec`
INSERT INTO users (name, email) VALUES (${name}, ${email})
RETURNING id
`;
return { id: result.id };
}
);
Encore automatically creates a PostgreSQL database — locally for dev, managed RDS/Cloud SQL for production.
Pub/Sub
import { Topic, Subscription } from "encore.dev/pubsub";
interface OrderEvent {
orderId: string;
userId: string;
total: number;
}
export const orderTopic = new Topic<OrderEvent>("orders", {
deliveryGuarantee: "at-least-once",
});
// Publish
await orderTopic.publish({
orderId: "ord_123",
userId: "usr_456",
total: 99.99,
});
// Subscribe
new Subscription(orderTopic, "process-order", {
handler: async (event) => {
console.log(`Processing order ${event.orderId}`);
// Send email, update inventory, etc.
},
});
Cron Jobs
import { CronJob } from "encore.dev/cron";
new CronJob("cleanup-expired", {
title: "Clean up expired sessions",
schedule: "0 * * * *", // Every hour
endpoint: cleanup,
});
const cleanup = api(
{ method: "POST", path: "/internal/cleanup" },
async () => {
await db.exec`DELETE FROM sessions WHERE expires_at < NOW()`;
return { status: "done" };
}
);
Auth Middleware
import { authHandler } from "encore.dev/auth";
import { Header } from "encore.dev/api";
interface AuthParams {
authorization: Header<"Authorization">;
}
interface AuthData {
userId: string;
role: string;
}
export const auth = authHandler(async (params: AuthParams): Promise<AuthData> => {
const token = params.authorization.replace("Bearer ", "");
const decoded = verifyJWT(token);
return { userId: decoded.sub, role: decoded.role };
});
// Protected endpoint
export const getProfile = api(
{ method: "GET", path: "/profile", auth: true },
async (_, { userId }: AuthData) => {
return db.queryRow`SELECT * FROM users WHERE id = ${userId}`;
}
);
Built-in Observability
Encore automatically generates:
- Distributed traces for every request
- Architecture diagrams from your code
- API documentation with request/response types
- Performance metrics per endpoint
All visible in the Encore dashboard — no Datadog or Grafana setup needed.
Deploy
# Deploy to Encore Cloud (free tier available)
git push encore
# Or self-host on your own AWS/GCP
encore app deploy --env=production
Need a backend built fast with zero infrastructure headaches?
📧 spinov001@gmail.com
🔧 My tools on Apify Store
Would you trade Terraform for automatic infra? Comment below!
Top comments (0)