Created
July 20, 2025 09:04
-
-
Save tluyben/bdcce04864d3fc7980dea6e846927204 to your computer and use it in GitHub Desktop.
Remove the NextJS dev indicator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use client'; | |
import { useEffect } from 'react'; | |
function removeNextJsDevIndicator(node: Node | ShadowRoot) { | |
if (!node) return; | |
// Try to remove the toast | |
const toast = (node as ShadowRoot | Document).querySelector?.('.nextjs-toast'); | |
if (toast) { | |
toast.remove(); | |
console.log('💣 Removed Next.js dev indicator'); | |
return true; | |
} | |
// Recurse through shadow roots | |
const treeWalker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT); | |
let currentNode = treeWalker.currentNode as HTMLElement; | |
while (currentNode) { | |
const maybeShadowHost = currentNode as HTMLElement; | |
if (maybeShadowHost.shadowRoot) { | |
if (removeNextJsDevIndicator(maybeShadowHost.shadowRoot)) return true; | |
} | |
currentNode = treeWalker.nextNode() as HTMLElement; | |
} | |
return false; | |
} | |
export default function DevIndicatorRemover() { | |
useEffect(() => { | |
const interval = setInterval(() => { | |
const removed = removeNextJsDevIndicator(document); | |
if (removed) clearInterval(interval); | |
}, 10); | |
return () => clearInterval(interval); | |
}, []); | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment