Skip to content

docs: Disable error redaction on dehydration when using Next.js #6771

Closed

Description

@Icestonks

Area of Improvement

In the new tRPC integration with React Query, there is no mention of disabling error redaction in Server Components when using Next.js. It could be helpful to include a small info card stating that if you are using Next.js, you should add something along the lines of the following:

new QueryClient({
    defaultOptions: {
        ...
        dehydrate: {
            ...
            shouldRedactErrors: (error) => {
                // We should not catch Next.js server errors
                // as that's how Next.js detects dynamic pages
                // so we cannot redact them.
                // Next.js also automatically redacts errors for us
                // with better digests.
                return false;
            },
        },
    },
});

Link to related docs

https://trpc.io/docs/client/tanstack-react-query/server-components#3-create-a-query-client-factory

Additional information

If it's not disabled, then Next.js doesn't recognize it's a dynamic page, and will throw an error during build.

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR implementing the suggested changes!

Activity

  1. added
    📚 documentation / examples
    on May 19, 2025
  2. jianwei0510 commented on May 22, 2025

    @jianwei0510

    You really save my day because I've tried to figure this error for two days when using pnpm build.

    Besides I used same way integrating with tRPC with two of my projects:

    1. using "next": "15.1.0" and "@tanstack/react-query": "^5.74.4" <-- work fine and don't encounter this error ✅
    2. using "next": "15.2.2" and "@tanstack/react-query": "^5.74.3" <-- Error: redacted ❎

    So I think this error may only happen in 15.2 or higher version next.js when ingrating with tRPC.

  3. KATT commented on Nov 2, 2026

    @KATT
    Member

    🤖 In v12, createTrpcRsc from @trpc12/tanstack-react-query/rsc handles this by default: when it dehydrates a pending query that later fails, it redacts the error unless the error has a digest, so Next still sees the errors it uses to detect dynamic rendering, and the build no longer fails with a redacted error. Setting dehydrate.shouldRedactErrors on your query client still overrides it. https://v12.trpc.io/v12/docs/integrations/rsc. v12 isn't released yet and there's no ETA.

  4. added
    next-major/definite
    on Nov 2, 2026
  5. hasanmahira commented on Nov 3, 2026

    @hasanmahira
    Contributor

    I’d like to pick this up for v11: a short note in the App Router setup and Server Components pages showing dehydrate.shouldRedactErrors so Next.js errors with a digest aren’t redacted. OK to go ahead?

  6. added a commit that references this issue on Nov 10, 2026
    57482b0
  7. github-actions commented on Nov 11, 2026

    @github-actions
    Contributor

    This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you.

  8. locked as resolved and limited conversation to collaborators on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-major/definite📚 documentation / examples

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions