{"success":true,"name":"default-stack-nextjs","description":"Use when building any web UI with no tech named. Next.js.","category":"software-development","path":"software-development/default-stack-nextjs/SKILL.md","file":"SKILL.md","content":"---\nname: default-stack-nextjs\ndescription: \"Use when building any web UI with no tech named. Next.js.\"\nversion: 1.1.0\nauthor: Hermes\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [nextjs, web, default-stack, owner-rule, dashboard]\n    related_skills: [i7-remote-ops]\n---\n\n# Default web stack = Next.js\n\n## When to Use\nThe user asks for anything he will look at in a browser — dashboard, admin panel, playground/test page, landing page, client site, API docs page, prototype — or asks to change one (including existing raw-HTML dashboards like AI Hub).\n\n## Rule\nWhen he does **not** name a technology, build it in **Next.js** (App Router). Never ship a raw `.html` file, a bare `http.createServer` page, or a static HTML dashboard as the product. If a backend API needs a page (playground, docs, admin), that page is Next.js; the API itself may stay a plain Node service.\n\nDoes not apply to: inline chat widgets rendered with `::preview` inside Hermes (HTML by design), pure backend APIs with no page, CLI scripts.\n\nSmall fixes to an existing raw-HTML dashboard are fine in place; offer the Next.js rebuild, don't silently start one.\n\n## How\n1. Next.js app (App Router, JS unless the repo uses TS), `next build && next start -p <port>` in production; no dev server for anything he keeps.\n2. An API can live in the same Next app (`app/api/.../route.js`) or stay a separate Node service with the Next app as its UI calling it server-side (route handlers proxy, so secrets never reach the browser).\n3. On [PRIVATE_HOST]: put it under `[PATH]<name>/` (or the Unitary repo when it belongs there), run as a systemd **user** service `brimind-<name>` like the others, `127.0.0.1` only.\n4. Match the existing Brimind look (dark, gold accent as on AI Hub / Unitary dashboards) and the existing UI language (AI Hub is in French) unless told otherwise.\n5. Prove it: `next build` passes, service active, `curl` the page returns 200, then show it (ssh -L or tunnel).\n\n## Dashboard conventions he expects (build them in from the start)\n- **The URL is the state; refresh keeps the place**: the open tab/section AND the open item (a discussion, a record) live in the URL (`#try/<id>` or a route segment). Opening an item = `history.pushState` (no reload) so Back/Forward move between items (listen to `popstate`); auto-assigned ids (e.g. the session id returned by the first message) use `replaceState`; a deep link in a new tab opens that item; `document.title` names it; sidebar entries are real `<a href>` links (Cmd-click opens a tab). Landing back on the home tab after F5 is a bug to him.\n- **Chat = a discussion, not a one-shot form**: a chat/tester UI keeps server-side sessions (sidebar of discussions with title · count · age, ＋ new, ✕ delete; bubbles; Enter sends, Shift+Enter newline) and each later message carries the earlier ones, whichever model answers.\n- **Stream every AI answer live** (text appears with a cursor as it arrives), even when the backend answers in one block — re-chunk it. Show provider · model · level as soon as the first piece arrives, and time-to-first-word + total at the end.\n- **Files and media in every AI input**: drop zone on the composer + click, quick-pick buttons (image / document / audio / video / any file), chips with image thumbnails or type icons, name, size and ✕, total size and the limits shown, client-side checks before upload.\n- **Anything that is an order is sortable by him**: priority lists (providers, fallback steps) get a rank number, drag handle and ▲/▼ buttons, saved server-side, and the order must actually drive behaviour (e.g. every chain re-sorted), not just the display.\n- **Show who did the work**: any AI answer shown in a UI states provider · model (name + real id) · intelligence level · attempt · ms, plus what failed before it. Offer a model + level picker (\"custom\") next to the preset chains.\n- **Make analytics self-explanatory**: trace each displayed metric back to its source before naming it; show what one row represents and distinguish sessions, messages and model calls. Display actual session IDs and recorded subjects or titles separately, mark missing data as “Not recorded” rather than substituting an agent name, and explain ambiguous counts and formulas in the UI. Identify whether costs are estimates or reported and whether each total uses the selected time window, because superficially similar sources may aggregate different units or periods.\n- **A feature added inside a long/scrollable tab needs its own jump button**: when you add a new section to an existing dashboard page (a new card, table or panel further down an already-long tab), also add a visible button in that tab's top toolbar that scrolls straight to it (`id` on the section + `scrollIntoView({behavior:'smooth'})` on click) — don't make him hunt for what he knows you just built by scrolling past everything else. Do this at ship time, not only after he asks for it a second time.\n- After a change, tell him to reload and exactly where to look (tab + row), in a table.\n\n## Pitfalls\n- The Next.js rule used to live only inside `i7-remote-ops/references/owner-preferences.md` and got missed; check this skill before writing any page.\n- [PRIVATE_HOST] runs hot: `next build` can take minutes; give the terminal call a long timeout and wrap with `timeout` on the [PRIVATE_HOST] side.\n- Inline `<script>` in an HTML dashboard isn't syntax-checked by anything: extract it to a scratch `.js` and run `node --check` before deploying.\n- Serve dashboard HTML with `Cache-Control: no-store`: a browser that cached the old page keeps running old JS after a deploy, so he reports \"it doesn't stream/work\" on a feature that is live. When a change ships to a page he already has open, tell him Cmd+Shift+R once.\n- Prove a UI change by driving it, not only the API behind it: headless Chrome (puppeteer) logs in, types + Enter, picks a file, reloads, uses Back/Forward, records `pageerror`, and takes a screenshot you look at before reporting — raw HTML showing up as text (e.g. an `<img>` escaped into a chip) only shows on the screenshot.\n","linked_files":[],"origin":"brimind","owner_id":null,"source":"router"}