Skip to main content

Introduction

Fakelab is a fast, easy-config mock API server for frontend developers. Generate realistic mock data from your TypeScript interfaces with Faker annotations.

Why Fakelab?โ€‹

  • ๐Ÿš€ Instant Setup - Get your mock server running in seconds
  • ๐Ÿ—‚๏ธ TypeScript First - Use your existing types and interfaces
  • ๐Ÿ“ฆ Lightweight - Minimal dependencies, fast performance
  • ๐Ÿ—„๏ธ Persistent Database - Built-in database mode with seeding
  • ๐Ÿ“ธ Snapshot Real APIs - Capture real API responses as mocks
  • ๐Ÿงช Perfect for Development - Ideal for local development, prototyping, and frontend testing

Quick Startโ€‹

  1. Install Fakelab:
npm install fakelab --save-dev
# or
pnpm add -D fakelab
# or
yarn add -D fakelab
  1. Create a configuration file:

Create fakelab.config.ts in your project root:

import { defineConfig } from "fakelab";

export default defineConfig({
sourcePath: ["./fixtures"],
server: { port: 50001 },
});
  1. Define your types with Faker annotations:
// fixtures/user.ts
export interface User {
/** @faker string.ulid */
id: string;
/** @faker person.fullName */
name: string;
/** @faker location.streetAddress */
address: string;
/** @faker phone.number */
phone: string;
/** @faker number.int({min:10,max:80}) */
age: number;
}
  1. Start the server:
npx fakelab serve

That's it! Your mock API is ready to use.

What's Next?โ€‹