Migrating Our Dashboard from React to Next.js

Migrating Our Dashboard from React to Next.js

Our signals dashboard started as a Create React App project, but as we grew, we needed more features and better performance. Here's how we migrated to Next.js and what we learned along the way.

Why Next.js?

We chose Next.js for several compelling reasons:

  1. Better Performance: Server-side rendering and automatic code splitting
  2. Enhanced SEO: Built-in head management and server rendering
  3. Developer Experience: Improved routing and API routes
  4. Built-in Optimizations: Image optimization and font loading

Key Benefits We've Seen

  • Faster Page Loads

    • Initial page loads reduced by 60%
    • Automatic image optimization
    • Better code splitting
  • Improved Development

    • Hot reloading is much faster
    • Better error handling
    • TypeScript integration

"The migration to Next.js has significantly improved both our user experience and developer productivity."

Migration Process

1. Project Structure

// Old structure (CRA)
src/
  components/
  pages/
  App.tsx
  index.tsx

// New structure (Next.js)
src/
  app/
    layout.tsx
    page.tsx
  components/

2. Routing Changes

Before:

<Router>
  <Route path="/" element={<Home />} />
  <Route path="/signals" element={<Signals />} />
</Router>

After:

// app/page.tsx
export default function Home() {
  return <HomePage />
}

// app/signals/page.tsx
export default function Signals() {
  return <SignalsPage />
}

3. Data Fetching

We moved from client-side fetching to server components where possible:

// Before (React)
useEffect(() => {
  fetch('/api/signals').then(...)
}, [])

// After (Next.js)
async function SignalsPage() {
  const data = await fetchSignals()
  return <SignalsList signals={data} />
}

Results

  • Performance

    • 60% faster page loads
    • 45% improvement in Core Web Vitals
    • Better SEO rankings
  • Developer Experience

    • Faster development cycles
    • Better debugging tools
    • Simplified deployment

Next Steps

  1. Implementing more server components
  2. Exploring Next.js 14 features
  3. Adding more performance optimizations

Feel free to reach out if you have questions about our migration process!