Fondu

Quick start

View as Markdown

Automatic installation

Copy this prompt and paste it into your coding agent. It will guide you through setting up a Fondu app, in a new project or an existing one, and answer your questions along the way.

Read https://fondu.dev/docs/quick-start.md, then help me create a Fondu app (or add Fondu to this project). Ask me where it will run (Bun, Cloudflare Workers or Node), set it up as the guide says, and explain each file you create.

Create an app

npm create fondu@latest my-app

It asks where the app runs: Bun, Cloudflare Workers or Node (or pass --target bun, --target cloudflare or --target node), and whether to add code checks (or pass --checks): oxfmt and oxlint, and VS Code settings that format on save; and whether to make a git repository (--git), unless the folder is in one. Then it writes a small app: one page, a layout, the error page, Tailwind CSS, editor snippets and an AGENTS.md for coding agents, and installs the dependencies with the package manager you ran it with (--no-install leaves that to you). --yes takes the defaults for what the options don't say, without asking, except for the target, which has none and must be given:

bun create fondu@latest my-app --target cloudflare --checks --yes

Run it

cd my-app
npm run dev

The app is at http://localhost:5173. Edit the page in app/routes/index.tsx and it updates in place; edit its loader and the page gets the new props, without a reload.

Add a page

A page is a route file: its loader, and the page component. Add app/routes/about.tsx:

import { defineHandler, render } from 'fondu'

// GET /about: runs on the server
export const loader = defineHandler((c) => render(c, About, { team: ['Ada', 'Grace'] }))

// the page: the part of the file the browser gets
export default function About({ team }: { team: string[] }) {
  return (
    <>
      <title>About</title>
      <h1>About</h1>
      <ul>
        {team.map((name) => (
          <li key={name}>{name}</li>
        ))}
      </ul>
    </>
  )
}

render(c, About, …) is checked against the page: a missing prop or one of the wrong type is a type error. Link to it with a plain <a> and a URL from href(), typed after your routes:

import { href } from 'fondu/client'

export const AboutLink = () => <a href={href('/about')}>About</a>

Build

npm run build

Then start on Bun or Node, or deploy on Cloudflare: Deploying has the details.

Next

Last updated