DocsGet started

An app’s shape

The folders a Sluurp app is made of, and what each one does.

An app is a folder of React and TypeScript. Where a file lives decides what it does, so there is little configuration to write.

package.json       # React, your packages and plugins (bun install); Sluurp's client comes with the server
components.json    # shadcn's settings; components/ui and components/sluurp
index.html         # a single-page app: its main.tsx, bundled by Bun
routes/            # or pages rendered on the server: routes/posts/[slug].tsx, docs/sync.md
islands/           # the interactive parts of server pages
functions/         # /api/fn/<name>, run on the server
hooks/             # <collection>.ts: beforeCreate, beforeUpdate…
jobs/              # scheduled: schedule = "0 7 * * *"
agents/            # react to changes in a collection
queues/            # <name>.ts handles ctx.queue(name) tasks
workflows/         # long-running steps that survive restarts
views/             # live views, their state on the server
i18n.json          # translations
schema.json        # collections, fields and rules
migrations/        # V1__*.json, V2__*.sql: changes to the data, in order
admin/             # your own screens and actions in the admin
plugins/           # plugins of the app's own, as folders, beside those installed from a registry

In the browser

An app with an index.html is a single-page app. Bun bundles it and updates it as you save.

An app with routes/ renders its pages on the server, from React server components and Markdown. Its islands and client components then run in the browser. See Server components.

  • Packages come from npm with bun add.
  • Components come from shadcn and Sluurp’s registry.
  • Tailwind needs no setup. Sluurp builds the stylesheet from the classes the app uses.

On the server

Functions, hooks, jobs, agents, views and server pages run on Bun, in workers. Server code reaches data through server, the same collections API the browser uses. A function or a server page acts as the person calling it, so every rule still applies. Jobs and agents have no caller, so they run as the system.

Several apps on one server

To serve several apps, pass --public once for each:

sluurp serve --public ./shop --public reports=./reports --public wiki=./wiki

The first app is served at /. Each named app is served at its own path (/reports/, /wiki/), with its own functions and jobs.

View as Markdown