Migration to v7
In React Router v6, you usedjson() to return JSON responses:
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 ajson() 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
data()- The v7 replacement forjson()- Migrating from v6 to v7 - Complete migration guide