From 178851d53d6e39b81bc73e7e6e35cd555124210b Mon Sep 17 00:00:00 2001 From: Dhruv Goyal Date: Fri, 9 Jan 2026 15:02:05 +0530 Subject: [PATCH] fix: redirect 404 page to /docs/ Fixes #3441 Updated NotFound component to automatically redirect users to /docs/ Signed-off-by: Dhruv Goyal --- src/theme/NotFound/Content/index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/theme/NotFound/Content/index.js b/src/theme/NotFound/Content/index.js index 7414dc0cf..f975d3109 100644 --- a/src/theme/NotFound/Content/index.js +++ b/src/theme/NotFound/Content/index.js @@ -1,13 +1,12 @@ -import {useEffect} from "react"; +import React, { useEffect } from 'react'; +import { useHistory } from '@docusaurus/router'; + +export default function NotFoundContent() { + const history = useHistory(); -export default function NotFound() { useEffect(() => { - if (typeof window !== "undefined") { - // immediate redirect without adding to browser history - window.location.replace("/docs"); - } - }, []); + history.push('/docs/'); + }, [history]); - // render nothing (no content shown) return null; -} +} \ No newline at end of file