Skip to content

docs: server-actions page missing HTTP-verb surface (#488-#492) #572

@vivek7405

Description

@vivek7405

Problem

The public docs site server-actions page (docs/app/docs/server-actions/page.ts, served at https://docs.webjs.dev/docs/server-actions) documents only the original POST-only surface: the 'use server' two-marker convention, the import-rewrite/RPC stub, full-stack type safety, the wire format, CSRF, the route.ts / route() REST adapter, and validate (#245). It is MISSING the entire HTTP-verb action surface and its siblings that shipped later:

So the docs materially undersell server actions (they are more than Next's POST-only Server Actions), and a user reading only the site would not know GET caching, streaming, or cancellation exist.

Design / approach

Add a new section to the docs page covering the verb config exports and their semantics, with shorter subsections for streaming, cancellation, and SSR seeding. The framework AGENTS.md already has the authoritative prose for all of this (the "HTTP-verb actions via config exports (#488)" paragraph in the root AGENTS.md, plus packages/server/AGENTS.md actions.js / action-stream.js / action-seed.js module entries); mirror it into user-facing docs-site prose (do not just copy the agent docs verbatim, write it for a developer reading the site). Match the existing page's voice and structure (plain HTML in an html\...`template,

/

/

/

`).

Keep the GET-cache and invalidates SAFETY note prominent: public: true / a cached GET shares the response across users keyed by URL + args, so it is only for data identical for every visitor (the same rule as a page's export const revalidate).

Implementation notes (for the implementing agent)

  • Where to edit: docs/app/docs/server-actions/page.ts. Current <h2>/<h3> structure (for placement): "Defining a Server Action" (L10), "How the Import Rewrite Works" (L68), "Full-Stack Type Safety" (L107), "The Wire Format" (L140), "CSRF Protection" (L157), "REST Endpoints from Server Actions" (L166, with route() adapter L194 + Validating the Input L210 + CORS L246), "ActionResult Envelope" (L251), "Error Sanitisation" (L274), "Complete Example" (L282), "Plain HTML forms" (L367). A good home for the new section is AFTER "The Wire Format" / before "CSRF" (verbs + caching are core mechanics), or a dedicated "HTTP verbs, caching, and streaming" <h2> after the import-rewrite section.
  • Source of truth to mirror (do NOT invent semantics): root AGENTS.md section "HTTP-verb actions via config exports (#488)" and the "Streaming results (#489)" / "Cancellation (#492)" / SSR-seeding (#472) prose; packages/server/AGENTS.md actions.js, action-stream.js, action-seed.js, action-route.js module-map entries.
  • The sidebar already lists the page (docs/app/docs/layout.ts L44 { href: '/docs/server-actions', label: 'Server Actions' }), so no nav change is needed unless the section warrants its own page (it does not; keep it on the server-actions page).
  • Landmines:
    • Invariant 9: NO backtick characters inside the html\...`template body (the page is one bightml``); escape or avoid backticks in code samples (the page already uses
      with HTML-escaped entities like</{`, follow that).
    • Invariant 11 (prose punctuation): no em-dash, no space-hyphen-space or space-semicolon-space pause; the .claude/hooks/block-prose-punctuation.sh hook blocks new content with these.
    • Get the verb transport details right: a GET rides args in the URL (?a=) with a POST fallback over a 4KB cap, is CSRF-exempt, carries Cache-Control + a weak ETag (304 on If-None-Match) and X-Webjs-Tags, and reads the SSR seed first; a mutation sends the rich body (DELETE rides the URL), is CSRF-protected, and emits X-Webjs-Invalidate. A mismatched request method is a 405 + Allow.
    • A streamed result is never cached/ETagged/seeded; a mutation still emits X-Webjs-Invalidate.
  • Invariants to respect: docs-site pages are .ts returning html\...` (not markdown). Keep light DOM + the page's existing Tailwind/section conventions (docs/AGENTS.md`).
  • Tests + docs surfaces: docs pages have content tests under test/docs/ (e.g. docs-pages-well-formed.test.js, llms.test.mjs); ensure the page still parses/renders (the in-repo docs app boot + the test/docs/* suite). No framework-code change, so no unit/e2e beyond the docs render. Also confirm /docs/server-actions/llms.txt (the per-page llms route) still generates.

Acceptance criteria

  • The server-actions docs page documents export const method and the GET vs mutation transport differences.
  • It documents export const cache / tags / invalidates with the shared-cache SAFETY note for public/cached GETs.
  • It documents export const middleware (#490), streaming results (#489), cancellation via actionSignal() (#492), and SSR action-result seeding (#472), at least briefly with a code sample for streaming.
  • It notes the one-callable-function-per-configured-file rule.
  • No invariant-9 backticks / invariant-11 punctuation introduced; the docs app still boots and the test/docs/* suite passes.
  • Cross-checked against root AGENTS.md so the docs and the agent docs agree (no contradictions).

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions