Skip to main content
In React Router v7, the json() helper has been replaced by the data() function. This page is maintained for users migrating from v6.

Migration to v7

In React Router v6, you used json() to return JSON responses:
In React Router v7, simply return the data directly or use data() for custom headers/status:

Why the change?

React Router v7 automatically handles JSON serialization for you. You no longer need to wrap your data in a json() helper. This simplifies your code and reduces boilerplate.

Before (v6)

After (v7)

Common Migration Patterns

Simple data returns

With status codes

With headers

See Also