Introducing a new way to review your PRs.

Read the announcement

solana-foundation / explorer

Explorer for Solana clusters

View on GitHub

23 documents · Updated Nov 23, 2026

docs / application-runtime

Application runtime and composition

The Explorer is a Next.js application that combines a shared browser shell with route-specific views and data state. The root composition keeps cluster choice, common UI, styling, recovery, and telemetry consistent while nested layouts add only the state needed by a route.

Runtime model

The application receives a request through the Next.js App Router and builds the page from the root layout inward. Shared context is established first. A route layout then adds data context before its page renders the view.

flowchart TD
    Request[Browser request] --> Root[Root application layout]
    Root --> Shared[Shared UI and global contexts]
    Shared --> Route[Route and nested layouts]
    Route --> Page[Route page and child views]
    Root --> Recovery[Error and not-found handling]
    Root --> Telemetry[Request error telemetry]

The two child pages cover the main parts of this model: Application shell, navigation, and global UI explains the user-facing wrapper, and Cluster-aware data providers explains the state that supplies chain data to route views. User feedback collection explains the feedback surface that is placed in the shared composition.

Application composition

Application shell

The application shell is the common frame around Explorer routes. app/layout.tsx establishes document metadata and viewport behavior, loads the shared font and stylesheet, and places navigation, notices, route content, footer content, analytics, consent UI, and toasts in one page frame. It also adds optional bot protection at the document head for configured protected routes.

The shell also owns the top-level context order. Scroll-anchor state surrounds cluster state. Visibility and token information are then available to the page frame and route content. The feedback surface stays inside cluster state because it reads the active cluster. Analytics and cookie consent attach at the document body level rather than inside the page frame. The order matters because these providers expose state to the components below them.

For the user-facing details of navigation, responsive layout, and global UI, read Application shell, navigation, and global UI.

References: app/layout.tsx• L1-22 app/layout.tsx• L24-81 app/…/Navbar.tsx• L21-108 app/…/Footer.tsx• L8-26

Performance reporting

Performance reporting sends supported browser metrics to the consented analytics service without adding a new page-level concern. The analytics slot waits until Google Analytics or Google Tag Manager is ready, then WebVitalsReporter subscribes once so buffered metrics are recorded without duplicate reports.

The reporter maps the main Web Vitals to short analytics events and ignores unsupported or deprecated metrics. It rounds time values to whole milliseconds and keeps layout-shift values at useful ratio precision.

References: app/…/default.js• L15-24 app/…/default.js• L28-90 app/…/WebVitalsReporter.tsx• L1-12 app/…/web-vitals.ts• L3-46

Route composition

Nested layouts let the application keep a route's data state alive while its child pages change. This separates a route's shared header and tabs from the content shown in each tab. The address layout also acts as an account-type composition point: it selects the main account view and adds only the tabs supported by the account's data.

For an address route, the layout first creates the account data scope. It then loads the address account and optional token details before it renders the shared header, account summary, security notice, dynamic tabs, and the selected child view. Invalid addresses show an error instead of entering account loading, while failed account loads keep a retry path.

The address view adapts to account content rather than showing one fixed page shape. Parsed system accounts, token accounts, program accounts, compressed assets, subscriptions, and unknown accounts receive different views. Tabs are added from the same account classification, so navigation follows the data that the account can provide.

Route scopeRoute concernComposition role
RootAll Explorer routesProvides the application shell and shared contexts.
AddressOne account address and its tabsLoads account state and chooses account-specific presentation.
BlockOne slot and its tabsLoads block state and presents related block views.
EpochOne epochProvides epoch state to the epoch view.
TransactionTransaction details and instruction viewsCombines transaction, account, and instruction parsing state.
HomeLive dashboardAdds live cluster statistics, staking content, developer resources, and gated feature content locally.

The route tree uses the same root shell for normal Explorer pages and the transaction inspector. The inspector keeps its own page metadata while the transaction layout supplies the state needed for transaction views.

References: app/layout.tsx• L37-81 app/…/layout.tsx• L157-225 app/…/layout.tsx• L228-287 app/…/layout.tsx• L289-367 app/…/layout.tsx• L396-490 app/…/layout.tsx• L32-55 app/…/layout.tsx• L238-247 app/…/layout.tsx• L1-5 app/…/layout.tsx• L1-14 app/…/layout.tsx• L1-13 app/page.tsx• L28-47

Shared styling

Shared styling gives every route the same visual base before route components add local classes. app/…/styles.css is the global stylesheet. It restores the Explorer's type, link, form, table, spacing, color, motion, and responsive behavior around the Tailwind base and utility layers.

The root layout imports this stylesheet for the main application. The transaction inspector imports it in its own layout as well, so that entry point remains styled even when its route composition is distinct. app/…/index.ts supplies the Rubik font through the --explorer-default-font variable.

References: app/layout.tsx• L1 app/…/layout.tsx• L1 app/…/styles.css• L8-18 app/…/styles.css• L283-306 app/…/index.ts• L1-8

Error handling

Error handling gives users a recoverable view for route failures and a minimal fallback when the full application cannot render. The segment error UI records the error and offers a retry action. The not-found UI reports an invalid or missing route without treating it as a system failure.

The global error UI is intentionally smaller than the normal shell. It uses Next.js's generic error page and records the failure before returning a valid document. Route code can also call notFound() for invalid dynamic values, such as a slot that cannot be parsed.

References: app/error.tsx• L1-19 app/global-error.tsx• L1-24 app/not-found.tsx• L1-11 app/…/layout.tsx• L32-37

Instrumentation

Instrumentation connects Next.js runtime failures to Sentry in each server runtime. During startup it loads the configuration for Node.js or Edge execution. Next.js request failures then pass through the Sentry request-error hook.

This keeps error capture outside page composition. A route does not need to know which runtime handles it in order for request failures to reach the telemetry system.

References: instrumentation.ts• L1-13

Provider wiring

Providers turn the route tree into a shared state graph. The root cluster provider adapts Next.js URL state to the cluster entity. A cluster selection therefore controls both the active RPC endpoint and the health state seen by downstream providers.

The root composition also provides scroll-anchor registration, visibility-triggered work, and batched token metadata requests. Scroll anchors register elements by URL fragment and scroll to the first live target after navigation, but stop waiting if the user scrolls first. The feedback surface stays inside cluster state because it reads the active cluster. Analytics and cookie consent remain outside this provider chain because they do not need route data state. Route layouts add narrower state such as accounts, transactions, blocks, and epochs. The account provider groups nearby account requests into endpoint-scoped batches, while the block provider keeps slot data and leader context tied to the selected endpoint. The home page adds its statistics state locally so other routes do not need those requests.

When a provider depends on a selected cluster, its state is cleared or keyed for the current endpoint. Pending account batches are cancelled when their provider scope changes. Block results combine the requested block with nearby leader information when that lookup is available, but the block remains usable when leader data is not. For the full list of cluster-aware data flows and wallet integration, read Cluster-aware data providers.

Wallet state is not a root concern for every page. The wallet client is created where a wallet-enabled feature needs it, and it is selected from the current cluster so wallet discovery and stored connections stay network-specific. Each supported cluster maps to the Wallet Standard chain identifier used for discovery and signature requests; custom endpoints use the localnet identifier rather than claiming a public network.

References: app/layout.tsx• L7-10 app/layout.tsx• L51-78 app/…/scroll-anchor.tsx• L8-21 app/…/scroll-anchor.tsx• L23-65 app/…/scroll-anchor.tsx• L66-108 app/page.tsx• L28-47 app/…/cluster.tsx• L3-37 app/…/cluster-provider.tsx• L31-75 app/…/visibility.tsx• L9-53 app/…/token-info-batch-provider.tsx• L28-127 app/…/index.tsx• L194-249 app/…/index.tsx• L252-381 app/…/block.tsx• L41-53 app/…/block.tsx• L66-133 app/…/wallet-provider.tsx• L14-41 app/…/cluster-chain.ts• L1-27

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the root provider order aligned with hook ownership. Moving a provider can make shared UI read state before it exists.
  • When changing scroll-anchor registration, preserve fragment matching, weak target cleanup, and the rule that user scrolling cancels automatic movement.
  • When adding a nested layout provider, check which child routes need the state and whether the layout also owns their shared tabs or header.
  • When changing cluster URL rules, preserve endpoint-specific cache keys and reset behavior so data does not cross networks.
  • When changing account request batching, preserve the data mode, endpoint scope, delayed flush, and cancellation behavior so requests do not reach a stale provider tree.
  • When changing block enrichment, keep the block result available when leader lookup fails and keep absent child slots distinct from failed requests.
  • When changing global colors, type, or responsive rules, check both the root layout stylesheet import and the inspector layout import.
  • When changing error boundaries or instrumentation, keep the user recovery path and Sentry runtime coverage intact.
  • When changing the home dashboard's local state, keep its activation tied to the selected cluster so live statistics do not remain active after the page leaves or the network changes.
  • When changing analytics loading or consent gates, keep Web Vitals reporting behind a ready analytics provider and preserve one stable subscription.
  • When changing cluster-to-wallet mappings, keep the chain identifier aligned with the network used for wallet discovery and transaction previews.
  • When moving feedback UI in the root layout, keep it below the cluster provider because it reads the active cluster.
  • When changing bot protection in the root document, keep protected routes enabled only when the feature flag is active.
  • When changing address account classification or tab rules, keep the account summary, child route set, and account-specific navigation aligned.

Important failure modes

TriggerConsequenceGuard
A cluster change leaves a provider cache under the old endpointA page can show data from the previous networkClear or scope provider state by the active URL.
A route uses a provider hook outside its layout scopeThe hook throws instead of rendering the routeKeep the matching provider above every route that consumes it.
A delayed account batch fires after the provider scope changesResults can update stale state or use the wrong endpointCancel pending account fetch timers during scope cleanup.
A dynamic block value is not a valid safe integerThe route can attempt to fetch an invalid slotValidate the route value and use the not-found path.
A leader lookup fails during block loadingA valid block can lose its surrounding leader detailsTreat leader data as optional and keep the block fetch successful.
A global stylesheet import is removed from an entry layoutA route loses the shared visual baseKeep the stylesheet import in both the root and standalone inspector layouts.
Runtime-specific Sentry setup is omittedRequest failures in that runtime are not capturedLoad the Node.js or Edge Sentry configuration during instrumentation.
Home dashboard statistics remain active after the cluster or page changesThe application can keep unnecessary live work or show stale cluster dataTie dashboard activation to the current cluster and clean it up when the page is no longer active.
Web Vitals subscribe before the analytics provider is ready or subscribe more than onceMetrics can be dropped or reported twiceMount the reporter only after analytics is ready and pass its stable tracking callback.
A custom cluster is labeled as a public wallet chainWallets can preview or simulate a transaction against the wrong networkMap custom endpoints to solana:localnet.
Feedback UI is placed outside the cluster providerThe feedback surface cannot read the active clusterKeep it inside the cluster provider in the root composition.
A scroll target is not registered before the URL change is handledNavigation can land without moving to the requested fragmentRegister live targets through the scroll-anchor provider and retry when the route or query changes.
A user scrolls while a fragment target is still loadingAutomatic scrolling can take control away from the userDisable pending anchor movement after meaningful user scroll.
Bot protection is enabled without the protected-route list or flag guardProtected routes can lose the intended browser challenge or unprotected routes can receive it by mistakePass the configured protected routes only when the Bot ID feature flag is enabled.
Address classification and tab rules divergeAn account can show a view without its supporting route or expose a tab with no valid dataDerive account presentation and conditional tabs from the same account signals.

Key files

FileWhy to read it
app/layout.tsxShows the root document, shell, shared contexts, bot protection, analytics slot, and consent and toast surfaces.
app/page.tsxShows how the home dashboard adds local statistics state and composes its main product sections.
app/…/cluster.tsxShows how Next.js navigation supplies URL-backed cluster state to the application.
app/…/scroll-anchor.tsxShows how URL fragments connect to live page targets without overriding user scroll.
app/…/cluster-provider.tsxShows the cluster health contract that downstream providers use.
app/…/index.tsxShows endpoint-scoped account batching, account parsing, and the state exposed to account routes.
app/…/block.tsxShows slot-scoped block state and optional leader enrichment.
app/…/layout.tsxShows how transaction routes compose transaction, account, and instruction state.
app/…/layout.tsxShows how an address route combines account loading, account-specific presentation, and shared account navigation.
app/…/layout.tsxShows how a block route combines block data with related tabs and invalid-route handling.
app/…/styles.cssDefines the shared visual base and responsive rules used by route views.
app/error.tsx and app/global-error.tsxDefine route-level recovery and the minimal global failure document.
instrumentation.tsDefines runtime error setup and request-error capture.
app/…/default.js and app/…/WebVitalsReporter.tsxDefine consent-aware analytics loading and browser performance reporting.
app/…/cluster-chain.tsDefines the network identity used by wallet discovery and signature requests.
config/botid-middleware.mjsDefines the routes that can receive Bot ID protection.