8000 docs: Disable error redaction on dehydration when using Next.js · Issue #6771 · trpc/trpc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
docs: Disable error redaction on dehydration when using Next.js #6771
Open
@Icestonks

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0