@somnia-chain/explorer-sidebar
Explorer sidebar
The Somnia Explorer's sidebar, chain picker, top bar and shell, as a package. Today the explorer renders it around every page. When each product moves to its own repo, each app renders the same shell, so the explorer still looks and navigates like one product.
Live demo
Below, this site plays the Oracle zone. Oracle links and the tabs route inside this app; every other product opens the live explorer. Narrow the window to see the mobile drawer.
Open the demo full screen →Built to be embedded
How links resolve
Usage
The explorer: the default app
app-shell.tsx
tsx
"use client"
// apps/explorer/components/shell/app-shell.tsx: the explorer's default app
import { type LinkComponent, ExplorerShell } from "@somnia-chain/explorer-sidebar"
import { ZoneLink } from "@somnia-chain/zones"
import { usePathname } from "next/navigation"
export function AppShell({ children }: { children: React.ReactNode }) {
return (
<ExplorerShell
sidebar={{ currentPath: usePathname(), linkAs: ZoneLink as LinkComponent }}
topbar={{ actions: <ConnectWallet /> }}
>
{children}
</ExplorerShell>
)
}A product in its own repo
The explorer is Next.js multi-zones: its default app rewrites /oracle/* to the Oracle app, which forwards everything else back. See apps/explorer/ZONES.md.
oracle app
tsx
// A product app: a zone of the explorer (see somnia-platform-product-template).
// Pages live at their full paths, e.g. app/oracle/**.
// next.config.ts
import { withZones } from "@somnia-chain/zones/next"
import zones from "./zones.json" // a copy of the explorer's zones.json
export default withZones({}, { config: zones, zone: "somnia-oracle" })
// app/layout.tsx
import "@somnia-chain/explorer-sidebar/styles.css"
import "./globals.css" // @import "tailwindcss"; @import "@somnia-chain/ui/theme.css";
// components/shell.tsx
"use client"
import { type LinkComponent, ExplorerShell } from "@somnia-chain/explorer-sidebar"
import { ZoneLink } from "@somnia-chain/zones"
import { usePathname } from "next/navigation"
export function Shell({ children }: { children: React.ReactNode }) {
return (
// ZoneLink knows which zone serves each path:
// /oracle/* navigates client-side, /agents loads the explorer.
<ExplorerShell sidebar={{ currentPath: usePathname(), linkAs: ZoneLink as LinkComponent }}>
{children}
</ExplorerShell>
)
}The sidebar alone, in any React app
layout.tsx
tsx
import { ChainProvider, ExplorerSidebar, useChain } from "@somnia-chain/explorer-sidebar"
import "@somnia-chain/explorer-sidebar/styles.css"
<ChainProvider>
<div className="flex">
<ExplorerSidebar currentPath={location.pathname} zone={["/agents"]} explorerUrl="https://platform.somnia.network" />
<YourApp /> {/* useChain() gives the chain picked in the sidebar */}
</div>
</ChainProvider>Props
ExplorerShell
ExplorerSidebar