Skip to content

Instantly share code, notes, and snippets.

@tluyben
Created July 20, 2025 09:04
Show Gist options
  • Save tluyben/bdcce04864d3fc7980dea6e846927204 to your computer and use it in GitHub Desktop.
Save tluyben/bdcce04864d3fc7980dea6e846927204 to your computer and use it in GitHub Desktop.
Remove the NextJS dev indicator
'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