Learn how to build a modern dashboard using React and Node.js. Discover essential steps, architecture, and code examples to kick-start your next web development project.
Table of content
Dashboards are a cornerstone of today’s web applications, empowering users to visualize and manage data efficiently. In this tutorial, we’ll walk through creating a dashboard using React for the front-end and Node.js for the back-end. This stack offers flexibility, scalability, and rapid development — perfect for both startups and enterprise-level apps.
mkdir dashboard-backend
cd dashboard-backend
npm init -y
npm install express cors body-parser
// index.js
const express = require('express');
const cors = require('cors');
const app = express();
const PORT = 5000;
app.use(cors());
app.use(express.json());
let data = [
{ id: 1, widget: 'Revenue', value: 3500 },
{ id: 2, widget: 'Users', value: 234 },
];
app.get('/api/widgets', (req, res) => {
res.json(data);
});
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
This starts a simple REST API for dashboard widgets.
npx create-react-app dashboard-frontend
cd dashboard-frontend
npm install @mui/material axios
// src/components/Dashboard.js
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import { Card, CardContent, Typography } from '@mui/material';
export default function Dashboard() {
const [widgets, setWidgets] = useState([]);
useEffect(() => {
axios.get('http://localhost:5000/api/widgets')
.then(res => setWidgets(res.data));
}, []);
return (
<div style={{ display: 'flex', gap: '1rem' }}>
{widgets.map(widget => (
<Card key={widget.id}>
<CardContent>
<Typography variant="h5">{widget.widget}</Typography>
<Typography variant="h6" color="text.secondary">{widget.value}</Typography>
</CardContent>
</Card>
))}
</div>
);
}
// src/App.js
import React from 'react';
import Dashboard from './components/Dashboard';
function App() {
return (
<div>
<h1>My Dashboard</h1>
<Dashboard />
</div>
);
}
export default App;
Building a dashboard with React and Node.js is straightforward and highly customizable. Start simple, then iterate and add features as your needs grow. This robust stack will support your ambitions — from MVP dashboards to full-featured analytics platforms.