--- name: Page Builder description: Patterns for building list and detail pages with forms, filters, and data fetching --- # Page Builder Patterns Universal patterns for building pages. These apply to both public-facing and admin pages. ## When to Use - Building list pages with filtering, search, pagination - Building detail/edit pages with forms - Rendering mixed-type feeds or lists - Any page that fetches and displays data ## Core Principle **Remote-First: Put logic in data.remote.ts, keep pages as pure renderers.** See [using-remote-functions/REMOTE-FIRST.md](../using-remote-functions/REMOTE-FIRST.md) for the full pattern. ## Page Types | Type | Purpose | Reference | | ----------- | --------------------------------- | ---------------------------------- | | List Page | Display items with filters/search | [LIST-PAGE.md](./LIST-PAGE.md) | | Detail Page | View/edit single item with form | [DETAIL-PAGE.md](./DETAIL-PAGE.md) | | Feed Page | Mixed-type items with components | [FEED-PAGE.md](./FEED-PAGE.md) | ## Route Structure ``` src/routes/ └── [section]/ ├── +page.svelte # List page ├── data.remote.ts # Remote functions (queries, forms) └── [slug]/ └── +page.svelte # Detail page ``` ## Key Patterns ### 1. Component Mapping Map data types to components for clean rendering: ```svelte {#each items as item, index (index)} {@const Component = components.get(item.type)} {/each} ``` ### 2. Filter Forms (Auto-Submit) Native forms that update URL params on input: ```svelte