Feature Request: Add gone() helper for 410 responses (similar to notFound() 404) #85888
Closed
KodamarthyYasaswi
started this conversation in
Ideas
Replies: 1 comment
-
|
duplicate |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Add a built-in gone() helper to return 410 Gone responses, similar to notFound() for 404.
Simplify handling of pages that can return multiple response types (e.g., 200, 410) without manual NextResponse logic.
Improve SEO and crawler behavior by properly signaling permanently removed content to search engines like Google.
Reduce potential hydration or rendering issues when conditionally returning expired/removed pages.
Non-Goals
Background
Currently, Next.js provides notFound() to return a 404 response easily, but there is no equivalent for 410 Gone.
Developers who want to return a 410 must manually create NextResponse objects, which adds boilerplate and can lead to hydration or rendering issues in page.tsx when multiple response types are possible.
SEO and search engine behavior benefit from 410 responses, as Googlebot treats them as permanent removals, allowing faster deindexing compared to 404.
Existing workarounds (manual NextResponse, custom error pages, or redirects) are less intuitive, inconsistent with Next.js conventions, and more error-prone.
Proposal
Introduce a new helper function, gone(), similar to notFound(), that returns a 410 Gone response from page.tsx, route handlers, or server components.
The API should be consistent with existing Next.js helpers:
import { gone } from 'next/navigation';
export default function Page({ data }) {
if (!data) {
return gone(); // Returns a 410 response
}
return
}
Beta Was this translation helpful? Give feedback.
All reactions