you should simply not do that, unmounting canvas on route change eventually will crash the tab because you can only open a limited amount of canvases and it’s going to cause memory issues, jank and slowness. instead leave the canvas mounted and exchange contents. with ssr and ssg websites should feel instant, that is established by switching components instead of refreshing the whole page and the same applies to the canvas.
here’s an example of how fast threejs can be in a nextjs routing context: GitHub - pmndrs/react-three-next: React Three Fiber, Nextjs, Tailwind and Styled-components starter