req.get(name)

Reads the first query-string value with this name. Parameter: a string key. Returns: a string or undefined. To read all matching values, call req.getAll(name).
Example
const name = req.get('name') || 'world'

req.formData(options?)

Reads URL-encoded or multipart form data. Returns: a promise of form values, including request-owned uploads. The request body and upload limits apply.
Example
const values = await req.formData()

h(value)

Escapes a value for HTML text or a quoted attribute. Parameter: the value to display. Returns: an escaped string.
Example
<p><?= h(req.get('name') || 'world') ?></p>
Output — ?name=<b>Clover</b>
<p>&lt;b&gt;Clover&lt;/b&gt;</p>
Note: h() is not an escaping helper for JavaScript, CSS, or arbitrary URLs.

include(path, locals?)

Renders a local file into the current response. Parameters: a path relative to the calling file, and an optional input object. Returns: a promise. Await it. Inputs are available as locals in the included file. Includes share request context and can nest up to 32 levels deep.
Example
await include('./_welcome.cow', { name: 'Clover' })

res.json(value?)

With a value, sends a JSON response and finishes it. With no argument, selects the JSON content type without finishing. Set other response metadata before output is committed.
Example
res.json({ hello: 'herd' })
Output
{"hello":"herd"}

res.status(code)

Sets the HTTP response status before headers are committed. Parameter: a valid status code. You can chain it with a response method.
Example
res.status(404).send('Not found')

More page APIs

APIPurpose
req.method()Read the HTTP method.
req.header(name)Read a request header.
req.json()Read the request body as JSON.
echo(...values)Append response output.
res.setHeader(name, value)Set an outgoing header.
res.redirect(location, status?)Finish with a redirect.
cow.signalObserve request cancellation.
cow.onCleanup(callback)Register request cleanup.
cow.track(promise)Track asynchronous work within the request.
See the guides for sessions, SQLite, uploads, streaming, and their detailed behavior. This reference covers core page APIs. Version-zero APIs can change.