`serverFetch` / `fetch`: move `context` into `init`

Open
#4,822 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@pi0 is already working on this.

Since Oct 26, 2026.

  • #4920 by @kanchingyg — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Compare the serverFetch and fetch implementations in src/runtime/nitro.ts and src/runtime/internal/app.ts, then read their descriptions in docs/1.docs/62.utils.md. First clarify whether the implementations should be unified or their differences documented, and how the proposed init.context change handles the breaking-change concern. Done means the chosen behavior is consistent between the API and its documentation.

Written by the indexing model from the issue text.

Description

breaking change discussion

serverFetch(resource, init, context) and fetch(resource, init, context) take context as a third positional argument (src/runtime/nitro.ts, src/runtime/internal/app.ts). Moving it to init.context would match the standard fetch signature and leave room to grow. Changing it after RC would be breaking.

Related: nitro and nitro/app export different implementations. The nitro one looks up the app on globalThis.__nitro__ / __nitro_builder__ and works outside the bundle; the nitro/app one calls useNitroApp(). docs/1.docs/62.utils.md describes them as the same, so we should either document the difference or unify them.

Opened with AI assistance.

Dominant language
TypeScript
Stars
11.5k
Forks
968
Avg merge
4d 9h
Merged PRs (30d)
64

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nitrojs/nitro

All issues in nitrojs/nitro

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.