Skip to content
Hedystia 2.5 - Typed Routing, Smart Caching & Static Islands

Hedystia

Build your whole application.

A TypeScript ecosystem for your data, interfaces and APIs. Use the ORM, reactive UI, routing, caching and server packages independently, or combine them around shared types.

database.ts
ts
import { database, integer, table, varchar } from "@hedystia/db";

const users = table("users", {
  id: integer().primaryKey().autoIncrement(),
  name: varchar(80).notNull(),
});

const db = database({
  schemas: { users },
  database: "sqlite",
  connection: { filename: "./app.db" },
  syncSchemas: true,
});

await db.initialize();
await db.users.insert({ name: "Ada" });

The Hedystia ecosystem

Choose the pieces your application needs.

Start with a database, a reactive interface or an API. Each package has its own installation and guide, so you can adopt the ecosystem one piece at a time.

Reactive interfaces. Typed navigation.

View updates native DOM nodes with signals. Router adds typed destinations and cached loaders. Render static HTML and activate interactive islands with Astro or standalone View builds.

View · fine-grained reactivity

Guide
tsx
import { sig, val, set } from "@hedystia/view";

export default function Counter() {
  const count = sig(0);

  return (
    <button onClick={() => set(count, val(count) + 1)}>
      Count: {() => val(count)}
    </button>
  );
}

Router · typed paths and loaders

Guide
tsx
import { createRoute, createRouter } from "@hedystia/router";

const user = createRoute("/users/$id", {
  loader: ({ params }) => ({ name: params.id }),
  component: ({ data }) => <h1>{() => data().name}</h1>,
});

const router = createRouter({
  routes: [user],
  viewTransitions: true,
});

router.mount(document.getElementById("app")!);
await router.navigate({
  to: "/users/$id",
  params: { id: "Ada" },
});

Connect your API to your application.

Define API contracts once and carry them into your HTTP client. Add the ORM, reactive UI and application tools where you need them.

SERVER CONFIGURATION

server.ts
ts
import { Hedystia, h } from "hedystia";

export const app = new Hedystia().post(
  "/users",
  ({ body }) => ({ id: 1, name: body.name }),
  {
    body: h.object({ name: h.string() }),
    response: h.object({
      id: h.number(),
      name: h.string(),
    }),
  },
);

app.listen(3000);

CLIENT INTEGRATION

client.ts
ts
import { createClient } from "@hedystia/client";
import type { app } from "./server";

const client = createClient<typeof app>("http://localhost:3000");

const { data, error } = await client.users.post({
  body: { name: "Ada" },
});

Trusted By & Contributors