Quick Start

Get up and running with TableCraft in 5 minutes.

1

Installation

Install the core engine, frontend components, and the adapter for your backend framework.

# Install core, table, and Hono adapter
pnpm add @tablecraft/engine @tablecraft/table @tablecraft/adapter-hono

# Install codegen as dev dependency
pnpm add -D @tablecraft/codegen
2

Define Your Table

Create a table configuration file. This defines how your table behaves, including search, sort, and filter capabilities.

// src/tables/products.ts
import { defineTable } from "@tablecraft/engine";
import { products } from "../db/schema";

export const productsConfig = defineTable(products)
  .name("products")
  .search("name", "description")
  .sort("-createdAt")
  .filter("category", "isArchived")
  .pageSize(20)
  .toConfig();
circle-info

Make sure your database schema is already defined. TableCraft works with your existing Drizzle ORM schema.

3

Create API Routes

Mount the TableCraft engine at /api/engine. Choose your framework below:

// src/index.ts
import { Hono } from "hono";
import { createHonoApp } from "@tablecraft/adapter-hono";
import { db } from "./db";
import * as schema from "./db/schema";
import { productsConfig } from "./tables/products";

const app = new Hono();

// Mount TableCraft engine at /api/engine
app.route(
  "/api/engine",
  createHonoApp({
    db,
    schema,
    configs: { products: productsConfig },
  }),
);

export default app;
4

Setup Styles (Tailwind CSS v4)

Import the table styles and add the @source directive so Tailwind picks up the utility classes used by @tablecraft/table:

/* src/index.css */
@import "tailwindcss";
@import "@tablecraft/table/styles.css";

@source "../node_modules/@tablecraft/table/src";
circle-info

The @source path is relative to your CSS file, not the project root. If your CSS file is deeper (e.g. apps/web/src/index.css), adjust accordingly: @source "../../../node_modules/@tablecraft/table/src";

5

Generate Types

Run the codegen tool to introspect your API and generate type-safe client adapters.

npx @tablecraft/codegen --url http://localhost:3000/api/engine --out ./src/generated
circle-exclamation
6

Create DataTable Page

Import the generated adapter and use it with the DataTable component.

// src/pages/products-page.tsx
import { DataTable } from "@tablecraft/table";
import { createProductsAdapter, type ProductsRow } from "../generated";

export function ProductsPage() {
  // Initialize the adapter with your API base URL
  const adapter = createProductsAdapter({
    baseUrl: "/api/engine",
  });

  return (
    <DataTable<ProductsRow>
      adapter={adapter}
      config={{
        enableSearch: true,
        enableExport: true,
        enableColumnResizing: true,
      }}
    />
  );
}

Next Steps

Explore more features to customize your tables.

Last updated

Was this helpful?