Skip to Content
The Public InterfaceSeptember 12, 2026

The Public Interface

August 20, 2026

HTTP Forms

HTTP forms using the JavaScript Fetch API.

By Ross Robinojavascript / http

HTML forms are the fundamental building block that allow users to submit data to a web server. HTML forms can be submitted as either a GET or POST request (other HTTP methods are not supported).

The action attribute specifies the URL or pathname of the route that handles the submission.

HTML forms can be submitted without client side JavaScript, or programmatically with JavaScript.

Submitting the form creates a Request to the route specified in the action.

For POST requests, request.body is a ReadableStream<Uint8Array> that streams the values the user submitted in the form.

For example, if a user submits the form above with name set to ross and title set to developer, the raw request body can be read with await req.text().

The buffered text from the request would look like this:

For GET requests, the inputs are added to the URL as URLSearchParams.

If the same form were submitted with method="GET", req.url would contain the query string.

You can then parse the URL and read each value from searchParams.

The enctype attribute can be used to change the encoding type of the form submission. Most commonly, enctype="multipart/form-data" allows forms to be submitted with File inputs.

If you build a FormData object and send it with fetch, the browser sends it as multipart/form-data automatically regardless of the form’s enctype attribute.

Instead of encoding the body as a single query string, multipart submissions split the request into sections separated by a boundary. This boundary is sent in the Content-Type header of the request for the server to use to find where each part starts and ends.

If the user uploads a large video file named video.mp4, the file part can take a while to load across the network. This is why large uploads are better handled as a stream instead of being buffered all at once.

Web servers can read the request created from the form. The incoming Request object is made available modern JavaScript servers typically on the argument of the request handler. For example, Hono makes the Request available on the Context within each middleware.

The Request.formData method is a built-in method available to parse the body of a POST request. It works the same regardless of the enctype attribute of the form.

The main disadvantage of using this method is that it forces you to load the entire body of the request into your server memory instead of being able to stream through your server to another source.

For GET requests, the data is contained within the Request.url string directly instead of within the body. The easiest way to obtain the data is creating a URL object with the URL string, and then accessing the searchParams property from there.

Since users are able to submit any sort of form data or search parameters to your server, you must treat them as untrusted data.

Frameworks provide a variety of ways to validate user inputs. Primarily libraries like Zod allow users to validate inputs at runtime to ensure data is the correct type.

There are a variety of packages that help servers efficiently and securely parse and stream form data. Check out my cross platform, low memory multipart parser here.…

Continue reading

In brief

Classy Typescript

A case for object oriented programming with modern TypeScript.

In the age of AI writing a larger percentage of code, one thing that I take pride in is code style, naming, and API design. I just released ovr@v6.0.0 and refactored the entire codebase to have everything defined on classes. Here’s the entire top-level API: There are a variety of benefits that I’ve realized through writing my code like this.

December 23, 2025

NPM Trusted Publishing

How to publish with provenance to NPM using GitHub Actions and Changesets.

NPM security requirements recently got an upgrade, meaning package authors need to adjust their publishing workflows if they were using NPM tokens. I encountered a few issues migrating my projects so here are my notes on how I’ve set up my release automation with GitHub Actions, Turborepo, Changesets. I’ll walk through the process of upgrading a css library I maintain called uico, here’s the repository if you want to see more details.

December 17, 2025

Simple Memoization in TypeScript

A tiny class to memoize a function in TS.

JavaScript isn’t the fastest language, it’s best to make sure repeated async operations and expensive computations aren’t done repeatedly. Here’s a Memo class that ensures whether it be an async function that has latency, or an expensive mathematical computation, the same operations are not running multiple times. This memo class creates a trie for each function using each argument it is called with. Async calls link to the same result so they are not called twice even if the async call hasn’t completed yet!

November 12, 2025

External dispatch

Archive

June 12, 2025 · javascript

Async Local Storage

Learn how to make use of AsyncLocalStorage in server-side JavaScript applications.

April 18, 2025 · gpt

OpenAI Responses API for TypeScript Developers

A simple overview of how to use the OpenAI Responses API with TypeScript, including setup, streaming responses, and managing conversation state without a database.

February 12, 2025 · javascript

JSDoc @import Tag

A better way to write types with JSDoc comments.

January 17, 2025 · javascript

Package Your TSConfig

How to publish and share your TypeScript configuration between projects.

June 7, 2024 · javascript

Create Your Own Vite Plugin

Understand modern development tooling by building a basic Vite plugin with LinkeDOM.

March 13, 2024 · css

Scope JavaScript and CSS with the Web Platform

CSS @scope combined with custom elements in JavaScript introduces a more native approach to scoping, allowing for cleaner and more manageable code in web development.

August 21, 2023 · css

A Case for CSS Components

Reasons to use CSS stylesheets instead of JavaScript UI frameworks to author primitive components.