Skip to content

[Replacement]: replace form-data with native FormData (and fetch) #482

@tbroyer

Description

@tbroyer

Package to replace

form-data

Suggested replacement(s)

In many (if not most) cases, the native FormData (https://nodejs.org/docs/latest/api/globals.html#class-formdata, https://developer.mozilla.org/en-US/docs/Web/API/FormData) could be used instead with no change.

There are some usages of the form-data library that require some code changes though:

  • using streams or directly a Buffer: those need to be turned into a Blob (possibly through node:stream/consumers)
  • the submit() method: can be replaced with fetch()
  • a few other specific methods that might not all have replacements (e.g. getBoundary/setBoundary)

Manifest type

native (replaceable by a built-in platform feature)

Rationale

The package mostly duplicates the native FormData

Availability

Node v18 without flags, v21 as non-experimental.
In browsers for 14 years!

Code example (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions