@molecule/app-root-error-boundary-svelte

Feature · error-boundary · App (browser) · v1.1.1 · Apache-2.0

Top-level Svelte error boundary that logs render errors via the bonded app logger and shows a minimal recovery surface

npm install @molecule/app-root-error-boundary-svelte

npm · Source on GitHub

How it works

@molecule/app-root-error-boundary-svelte is a ready-made error-boundary feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { RootErrorBoundary } from '@molecule/app-root-error-boundary-svelte'
  import App from './App.svelte'
</script>

<RootErrorBoundary>
  <App />
</RootErrorBoundary>

Works with: @molecule/app-i18n, @molecule/app-logger, @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte top-level error boundary — the counterpart of @molecule/app-root-error-boundary-react: the same props and the same DOM for the same input.

Exports <RootErrorBoundary> (the children snippet is the only prop). Mount it directly under your routing root so it covers the whole route tree.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { RootErrorBoundary } from '@molecule/app-root-error-boundary-svelte'
  import App from './App.svelte'
</script>

<RootErrorBoundary>
  <App />
</RootErrorBoundary>

Type

feature

Installation

npm install @molecule/app-root-error-boundary-svelte @molecule/app-i18n @molecule/app-logger @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Constants

RootErrorBoundary

const RootErrorBoundary: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-i18n ^1.0.1
  • @molecule/app-logger ^1.0.1
  • @molecule/app-svelte ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-i18n

  • @molecule/app-logger

  • @molecule/app-svelte

  • @molecule/app-ui

  • @molecule/app-ui-svelte

  • svelte

  • The fallback UI styles itself via getClassMap() — if no ClassMap is bonded the boundary itself throws while rendering the fallback. Ensure setClassMap() runs during bootstrap, before anything can error.

  • There is no retry/reload action — the fallback is a static message (key error.unknown). Wrap or fork when you need a recovery button.

  • The boundary catches RENDER errors only — not event handlers, async code, or server-side rendering errors.

  • The fallback translates through useTranslation(), so it re-renders in the new language after a locale switch. No setMoleculeContext is required: outside one it reads the bonded @molecule/app-i18n provider, and without locale registration it falls back to English. Translations: @molecule/app-locales-root-error-boundary.

Translations

Translation strings are provided by @molecule/app-locales-root-error-boundary.