Next.js & EVM Node Configuration

Environment Variables: In .env.local:

NEXT_PUBLIC_EVM_RPC_URL=http://localhost:8545
NEXT_PUBLIC_CHAIN_ID=9999
NEXT_PUBLIC_API_BASE_URL=http://localhost:3001/api

Next.js Configuration (next.config.js):

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  env: {
    EVM_RPC_URL: process.env.NEXT_PUBLIC_EVM_RPC_URL,
    CHAIN_ID: process.env.NEXT_PUBLIC_CHAIN_ID,
  },
  images: {
    domains: ['/image/logo.svg'],
  },
  async rewrites() {
    return [{ source: '/api/:path*', destination: process.env.NEXT_PUBLIC_API_BASE_URL + '/:path*' }];
  },
};
module.exports = nextConfig;

EVM Node Connection:

  • Use Ether.js in frontend/src/lib/ethers.ts:

  • Wrap application with Ethers react context (<Web3ReactProvider>).

Caching & Performance:

  • Enable SWR or React Query with stale‑while‑revalidate for RPC calls.

  • Use incremental static regeneration (ISR) for dashboard pages:

Error Handling & Logging:

  • Configure Sentry or LogRocket in _app.tsx for runtime monitoring.

  • Centralize RPC error handling in a custom hook (useRpcCall).

Last updated