Skip to main content
Semola is designed for Bun, but works with any package manager. Choose your preferred tool below.

Install Semola

bun add semola

Install a validation library

Semola uses the Standard Schema specification, which means you can use any compatible validation library.
We recommend Zod for its excellent TypeScript integration and developer experience.
bun add zod

Alternative validation libraries

You can also use:

Optional dependencies

Some Semola modules require additional setup:

Redis-dependent modules

The following modules require a Redis client:
  • semola/queue - Background job processing
  • semola/pubsub - Real-time messaging
  • semola/cache - Caching with TTL
1

Install a Redis client

Bun includes a built-in Redis client. No additional installation needed.
2

Set up Redis server

You need a Redis server running. For development:
docker run -d -p 6379:6379 redis:alpine
3

Connect to Redis

Create a Redis client in your application:
const redis = Bun.redis({
  hostname: "localhost",
  port: 6379,
});
For production, use a managed Redis service like Upstash, Redis Cloud, or AWS ElastiCache.

Verify installation

Create a simple test file to verify everything is working:
test.ts
import { Api } from "semola/api";
import { z } from "zod";

const api = new Api();

api.defineRoute({
  path: "/health",
  method: "GET",
  response: {
    200: z.object({ status: z.string() }),
  },
  handler: async (ctx) => {
    return ctx.json(200, { status: "ok" });
  },
});

api.serve(3000, () => {
  console.log("Server running on http://localhost:3000");
});
Run the file:
bun test.ts
Visit http://localhost:3000/health to see your API in action.

TypeScript configuration

Semola requires TypeScript 5.0 or higher. Your tsconfig.json should include:
tsconfig.json
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "types": ["bun-types"]
  }
}

Next steps

Quickstart

Build your first API in under 5 minutes

Build docs developers (and LLMs) love