Skip to main content

data

data

Framework Data

Summary

Reference Documentation ↗

Create "responses" that contain headers/status without forcing serialization into an actual Response

import { data } from "react-router";

export async function action({ request }: Route.ActionArgs) {
  let formData = await request.formData();
  let item = await createItem(formData);
  return data(item, {
    headers: { "X-Custom-Header": "value" }
    status: 201,
  });
}

Signature

function data<D>(data: D, init?: number | ResponseInit)

Params

data

The data to be included in the response.

init

The status code or a ResponseInit object to be included in the response.

Returns

A DataWithResponseInit instance containing the data and response init.

Translation © 2026 fanyi.dev · Original © 2026 React Training LLC, Remix Software Inc., Shopify Inc. (MIT)