How blockscout/frontend works
Project type and purpose
• This is a Next.js-based frontend application for Blockscout, an open-source blockchain explorer.
• It provides server-side rendering (SSR) and static site generation (SSG) of pages that display blocks, transactions, addresses, tokens, L2 batches/withdrawals, user operations, contract verification, analytics dashboards, etc.
File structure
• Top-level directories:
• pages/ – Next.js pages (SSR/SSG, API routes under pages/api)
• nextjs/ – Next.js custom routing, CSP, middleware, headers, rewrites/redirects
• ui/ & toolkit/ – React components and design system (Chakra UI wrappers, shared widgets)
• lib/ – Low-level API clients, hooks, utilities, socket contexts, feature-flag integration
• configs/ – Environment and feature-flag configuration, per-network ENVs
• deploy/ & .github/workflows – CI/CD and deployment manifests (Dockerfile, Helmfile, GitHub Actions)
• Patterns:
• Hybrid SSR/CSR with Next.js page conventions
• Feature flags via GrowthBook and configs/app/features
• Modular “ui” and “toolkit” libraries for shared components
• API-first design: lib/api contains fetch hooks and service wrappers
README insights
• Distributed as a Docker image; configured entirely via environment variables.
• Backend is decoupled: frontend calls the Blockscout REST/GraphQL APIs and WebSocket endpoints exposed by the Blockscout backend (not part of this repo).
• Supports custom builds, local development via devcontainer, and multiple network environments.
Details to capture
• Next.js page lifecycle: getServerSideProps, getStaticProps, client fetch hooks
• API proxy layer under pages/api
• WebSocket context usage for real-time notifications
• Feature flag evaluation at server and client
• Static asset flow: build → public folder → CDN