If your TanStack Start dev server prints “Error in renderToReadableStream: { isNotFound: true }” when you open a page, a page component threw notFound() while the server was rendering it. The browser still shows your 404 page, but the server answers with the status code 200. This post shows the error, the docs line that explains it, and the fix: throw notFound() from the route’s loader.
What I Was Doing
I was giving every book its own page in a TanStack Start app, the Bookshop, while writing TanStack Start Tutorial — Part 4: Dynamic Routes and Path Params. The route file looked for the book in its component and threw notFound() when there was none:
import { createFileRoute, notFound } from "@tanstack/react-router";
import { books } from "#/lib/books";
export const Route = createFileRoute("/books/$bookId")({ component: BookPage });
function BookPage() {
const { bookId } = Route.useParams();
const book = books.find((book) => book.id === bookId);
if (book === undefined) {
throw notFound();
}
return (
<main className="mx-auto max-w-2xl p-8">
<h1 className="text-4xl font-bold">{book.title}</h1>
<p className="mt-4 text-lg">by {book.author}</p>
</main>
);
}
Then I opened an address with a book ID that doesn’t exist: http://localhost:3000/books/99.
What I Expected
The app’s 404 page, from the root route’s notFoundComponent, with the status code 404, so that browsers and search engines know the page doesn’t exist.
What I Got
The browser showed the 404 page, but the terminal running the dev server printed an error:
Error in renderToReadableStream: { isNotFound: true } { componentStack: [Getter] }
4:18:02 PM [vite] (client) [console.error] { isNotFound: true, routeId: "__root__" }
The above error occurred in the <BookPage> component.
React will try to recreate this component tree from scratch using the error boundary you provided, CatchBoundary.

What I Checked
The page looked right, so the one check that mattered was the status code the server sent. curl -I asks for the response’s headers only:
curl -I http://localhost:3000/books/99
HTTP/1.1 200
Vary: Origin
content-type: text/html; charset=utf-8
The server answered 200, as for a page that exists. TanStack Router’s Not Found Errors guide (opens in a new tab) allows throwing notFound() in components, but recommends throwing it in loaders instead, “to correctly type loader data and prevent flickering”.
Why It Happens
The loader and the component run at different times. TanStack Start runs a route’s loader before it renders the page, so a notFound() thrown there is known before any HTML goes out, and the server sends the 404 page with the status code 404.
A component runs while React renders the page into HTML on the server, which is what renderToReadableStream (opens in a new tab), named in the error, does. A notFound() thrown there breaks off that render: the server’s page arrives with the status code 200 and only the header, and React then rebuilds the page in the browser from the nearest error boundary, as its message says. That’s how the 404 page still appears.
The Fix
Move the lookup and notFound() into the route’s loader, and read the book in the component with Route.useLoaderData():
import { createFileRoute, notFound } from "@tanstack/react-router";
import { books } from "#/lib/books";
export const Route = createFileRoute("/books/$bookId")({
loader: ({ params }) => {
const book = books.find((book) => book.id === params.bookId);
if (book === undefined) {
throw notFound();
}
return book;
},
component: BookPage,
});
function BookPage() {
const book = Route.useLoaderData();
return (
<main className="mx-auto max-w-2xl p-8">
<h1 className="text-4xl font-bold">{book.title}</h1>
<p className="mt-4 text-lg">by {book.author}</p>
</main>
);
}
- The loader gets the path params as
params, so the component no longer needsRoute.useParams(). - The loader throws before it could return nothing, so TypeScript knows the component always gets a book.
After the Fix
The terminal prints no error for /books/99, and the server answers with the status code 404:
curl -I http://localhost:3000/books/99
HTTP/1.1 404
Vary: Origin
content-type: text/html; charset=utf-8

The browser shows the same 404 page as before, now with the right status code.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Throwing notFound() in the component | The page looks right, but the status code is 200 and the terminal logs the error | Throw it in the route’s loader |
| Judging the fix by the page alone | The 404 page looks the same with either status code | Check the status code with curl -I |
Leaving the root route without a notFoundComponent | TanStack Router shows its plain default page, which only says “Not Found” | Add one, as in How to Add a Custom 404 Page in TanStack Start |
Troubleshooting
| Problem | Fix |
|---|---|
| The error comes back on another page | Look for notFound() in that page’s component, and move it to the route’s loader. |
| The terminal still shows the error after the change | Open the page again: the error belongs to the request that rendered it. |
FAQ
Is it ever right to throw notFound() in a component? TanStack Router allows it, and its CatchNotFound component can catch it there. Its docs still recommend loaders, which give the right status code and the right types for the loader’s data.
Can beforeLoad throw it too? Yes. The Not Found Errors guide (opens in a new tab) names both beforeLoad and loader as places to throw notFound().
Conclusion
Throw notFound() from the route’s loader, where TanStack Start learns about it before rendering. The 404 page then comes with the status code 404, the terminal stays quiet, and the component always gets a book.
Additional Resources
- Not Found Errors (opens in a new tab) in the TanStack Router docs, with “Throwing Not Found Errors in Components”
- notFound (opens in a new tab) reference
- Data Loading (opens in a new tab), with route loaders
- renderToReadableStream (opens in a new tab) in the React docs
Related
- TanStack Start Tutorial — Part 4: Dynamic Routes and Path Params
- How to Add a Custom 404 Page in TanStack Start
- TanStack Start Tutorial for Beginners, every part of the series
TanStack, React and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by TanStack.
0 comments