Guide
How a pg-web app is put together, topic by topic.
Being written. For now, see docs/APP-DEVELOPER-GUIDE.md and docs/APP-LAYOUT.md.
Planned chapters
| Chapter | Covers |
|---|---|
| App layout | Directory-as-route, filename-as-method |
| Handlers | The (req json) contract, responses, redirects, cookies |
| Templates | Tera, shared components, fragments for HTMX |
| Assets & settings | public/, pgweb.setting(), environments |
A taste of the handler contract
CREATE FUNCTION pgweb.pages__index(req json)
RETURNS json AS $$
SELECT json_build_object('todos',
(SELECT coalesce(json_agg(t), '[]'::json) FROM todos t));
$$ LANGUAGE sql;