Portal & ErrorBoundary in SolidJS
From the SolidJS cheat sheet ยท Portals & Error Boundaries ยท verified Jul 2026
Portal & ErrorBoundary
Render components into a different DOM node and catch errors in the component tree.
tsx
// Quick Reference
import { Portal } from "solid-js/web";
import { ErrorBoundary, Suspense } from "solid-js";
<Portal><div class="modal">Modal Content</div></Portal>
<ErrorBoundary fallback={<p>Error!</p>}><App /></ErrorBoundary>๐ก Portal renders children into a target DOM element outside the component hierarchy
โก ErrorBoundary fallback receives the error and a reset function to retry rendering
๐ Combine ErrorBoundary with Suspense for complete async error and loading handling
๐ข Portal defaults to document.body โ pass mount prop to target a specific element
portalerror-boundarysuspense