Build a Next JS Dashboard Tutorial with GitHub Code Examples

Logan Jul 13, 2026

Dive into the dynamic world of web development with Next.js, a React framework that delivers server-side rendering and static site generation out of the box. Today, we're going to create a comprehensive dashboard using Next.js and host it on Github. Let's get started!

admin dashboard using html css
admin dashboard using html css

Before we embark on this journey, make sure you have Node.js and npm installed. Also, familiarize yourself with React and its syntax. If you haven't installed the required tools, you can do so at nodejs.org.

two screens showing different dashboards and statistics
two screens showing different dashboards and statistics

Setting Up Your Development Environment

We'll begin by setting up a new Next.js project and installing the necessary dependencies.

GitHub - themeselection/materio-mui-nextjs-admin-template-free: An enterprise-grade Next.js admin dashboard template. Made with developer experience first: Next.js v14 (App Router), Material UI (MUI), Tailwind CSS, TypeScript, ESLint, Prettier, VSCode Configs !! 🚀
GitHub - themeselection/materio-mui-nextjs-admin-template-free: An enterprise-grade Next.js admin dashboard template. Made with developer experience first: Next.js v14 (App Router), Material UI (MUI), Tailwind CSS, TypeScript, ESLint, Prettier, VSCode Configs !! 🚀

Open your terminal or command prompt, navigate to the directory where you want to create your project, and run the following command to create a new Next.js application:

npx create-next-app@latest my-dashboard-app

Installing Dependencies

Дизайн дашборда
Дизайн дашборда

Next, we need to install some useful libraries to enhance our dashboard's functionality. Change into your project directory and run:

cd my-dashboard-app
npm install axios react-chartjs-2 chart.js

We've installed axios for API calls, and react-chartjs-2 along with chart.js to create interactive charts.

Initializing GitHub Repository

Add Dark Mode to Your Next.js + Tailwind CSS Website in 60 Seconds
Add Dark Mode to Your Next.js + Tailwind CSS Website in 60 Seconds

Now, let's initialize a Git repository and push our code to Github. In your terminal, run:

git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/yourusername/my-dashboard-app.git
git push -u origin master

Replace yourusername with your actual Github username.

Building the Dashboard

GitHub - williamtroup/Heat.js: 🌞 A highly customizable JavaScript library for generating interactive heatmaps. It transforms data into smooth, visually intuitive heat layers, making patterns and intensity easy to spot at a glance.
GitHub - williamtroup/Heat.js: 🌞 A highly customizable JavaScript library for generating interactive heatmaps. It transforms data into smooth, visually intuitive heat layers, making patterns and intensity easy to spot at a glance.

Now that our project is set up, let's create a simple dashboard with a welcome message, a chart, and some data fetched from an API.

Open the pages/index.js file in your favorite code editor. Replace the existing code with the following:

an image of a dashboard screen with various items on it
an image of a dashboard screen with various items on it
GitHub - Madelena/hass-config-public: My Dashboards for Home Assistant - Advanced data visualizations, responsive design, a neat maximalist Metro Live Tile layout, and an ultraminimal tablet layout!
GitHub - Madelena/hass-config-public: My Dashboards for Home Assistant - Advanced data visualizations, responsive design, a neat maximalist Metro Live Tile layout, and an ultraminimal tablet layout!
JavaScript Projects ideas for All Developer
JavaScript Projects ideas for All Developer
Tips for css style Animation
Tips for css style Animation
tg: webguild
tg: webguild
Productivity Workspace UI
Productivity Workspace UI
an image of a dashboard screen with purple squares and dots on the bottom right corner
an image of a dashboard screen with purple squares and dots on the bottom right corner
the dashboard screen shows different types of data and information, including numbers, times, and other things
the dashboard screen shows different types of data and information, including numbers, times, and other things
an image of a dashboard with many different things on it
an image of a dashboard with many different things on it
a computer screen with different types of buttons
a computer screen with different types of buttons
Getfierce.com - Home - Web App | Fiverr Solutions
Getfierce.com - Home - Web App | Fiverr Solutions
login and register form in HTML CSS #webdevelopment #software
login and register form in HTML CSS #webdevelopment #software
the dashboard screen is displaying various graphs and data, including an hour - to - minute clock
the dashboard screen is displaying various graphs and data, including an hour - to - minute clock
Github Cheatsheet
Github Cheatsheet
an invoicer is shown on top of a computer screen
an invoicer is shown on top of a computer screen
the dashboard screen is showing all different things in each section, including people's avatars
the dashboard screen is showing all different things in each section, including people's avatars
Admiro – React NextJS Admin & Dashboard Template
Admiro – React NextJS Admin & Dashboard Template
the dashboard screen shows that there are many different items in this page, including numbers and symbols
the dashboard screen shows that there are many different items in this page, including numbers and symbols
a computer screen with various dashboards and data on the monitor, as well as other screens
a computer screen with various dashboards and data on the monitor, as well as other screens
Dashboard Design
Dashboard Design

import {useEffect, useState} from 'react';
import {Bar} from 'react-chartjs-2';
import axios from 'axios';

function Home() {
  const [data, setData] = useState(null);
  const [chartData, setChartData] = useState(null);

  useEffect(() => {
    const fetchData = async () => {
      const result = await axios.get('https://jsonplaceholder.typicode.com/todos');
      setData(result.data);
      setChartData({
        labels: result.data.map(item => item.userId),
        datasets: [
          {
            label: 'Tasks',
            data: result.data.map(item => item.userId),
            backgroundColor: 'rgba(54, 162, 235, 0.2)',
            borderColor: 'rgba(54, 162, 235, 1)',
            borderWidth: 1
          }
        ]
      });
    };

    fetchData();
  }, []);

  if (!data || !chartData) return <div>Loading...</div>;

  return (
    <div>
      <h1>Welcome to my Dashboard</h1>
      <p>Fetched data: {JSON.stringify(data[0])}</p>
      <Bar
        data={chartData}
        width={100}
        height={50}
        options={{}}
      />
    </div>
  );
}

export default Home;

Here, we're fetching data from JSONPlaceholder, creating chart data, and displaying it using Bar component from react-chartjs-2.

Running the Application

Start the development server by running:

npm run dev

Open your browser and navigate to http://localhost:3000 to see your shiny new dashboard!

Deploying to Github Pages

Next.js apps can be exported as static sites, which we can deploy to Github Pages. Let's do that!

First, install the required dependency:

npm install next export-assets

Exporting the Application

Now, run the following command to export your application as a static site:

npm run build
export-assets.out static

Deploying to Github Pages

Create a new repository on Github called my-dashboard-app.github.io. Then, push your exported static site to this new repository:

git init
git add .
git commit -m "Export and deploy"
git remote remove origin
git remote add origin https://github.com/yourusername/my-dashboard-app.github.io.git
git push -u origin main

Within a few seconds, your dashboard should be live at https://yourusername.github.io/my-dashboard-app. Isn't that amazing?

And there you have it! You've successfully created, Git-hub-hosted, and deployed a Next.js dashboard. Happy coding, and remember to keep exploring and improving your dashboard as you learn more about web development!