Skip to content

Lighthouse / Working examples

Try a little.
Understand a lot.

Start with one request. Follow what happens. Then make one small change of your own.

01 / Frontend meets backend

Ask the server. Get an answer.

Press the button to ask this app whether its API is running. The response comes from Elysia, through Eden, back to your browser.

GET/api/health

Ready when you are. This sends a real request to this app.

No account or database needed. This checks the API, not the database or sign-in.

The request / simplified excerpt

const { data, error } = await api.api.health.get();

if (error) {
  // Show a helpful message and offer a retry.
}

// On success, data is { status: "ok" }.

You call an endpoint like a JavaScript function. Eden sends the request and reads the response. await waits for the answer without freezing the page.

The first api is our client variable. The second is the /api path. Your editor suggests the endpoints and their inputs from the server's type.

What happens on the server?

Inside src/server/api.ts, this Elysia route returns an ordinary object. Elysia turns it into the HTTP response.

.get("/health", () => ({ status: "ok" as const }))

Next.js sends /api/* requests through src/app/api/[[...route]]/route.ts to Elysia. Next.js still handles your pages, layouts, and server rendering. This catch-all arrangement also works with Hono.

Where do loading, errors, and cancellation go?

TanStack Query keeps track of this request. The component reads its fetching, error, and data values rather than copying them into React state. The request function passes its cancellation signal to Eden and rejects failed or unexpected responses so Query can show an error.

Follow the complete working code in src/components/examples/request-demo.tsx. The short excerpt above leaves out those controls so you can first see the request itself.

02 / Your included feature

A project that is still here tomorrow.

Create an account, save a project, and refresh the page. Your data stays in PostgreSQL, scoped to your account.

Requires the included auth + database

Try the whole path

  1. Submit an empty name. Notice the feedback and keyboard focus.
  2. Create a project with a valid name, then reload to check it was saved.
  3. Sign in with a second account. Its workspace should be separate.
Open the Projects workspace

Uses this app’s accounts and database. A hosted demo and your localhost app have separate data.

Follow the files

src/features/projects/

schema.ts
What input is allowed?
routes.ts
What does the server accept?
service.ts
What does the operation do?
api.ts
How does the browser call it?
queries.ts
How does the interface stay up to date?
Why validate on both sides?

The browser gives quick feedback. The server checks every request because anyone can call an API without using the form. Both use the same Zod schema. TypeScript helps while you write code; Zod checks the data that actually arrives.

Validation does not decide who owns a project. The session identifies the caller, and the service scopes database operations to that caller.

03 / Your turn

Make one change you can explain.

Reduce the project name limit in schema.ts from 80 to 60 and update its validation message. Try a 60-character name, then a 61-character name. Check both the form and the API tests. This stays within the existing database limit.

Before looking back at the code, explain where the input is checked and where the response comes from. Then check your explanation against the files. That is a useful learning checkpoint for you or a reviewer.

Build, verify, and review

In a generated app, docs/examples.md walks through your selected feature. docs/development-workflow.md connects that exercise to implementation and review.