Creating a Next.js Application Using Syncfusion® React Components

17 Mar 20253 minutes to read

This section provides a step-by-step guide for setting up a Next.js application and integrating the Syncfusion® React Circular Gauge component.

What is Next.js?

Next.js is a React framework that makes it easy to build fast, SEO-friendly, and user-friendly web applications. It provides features such as server-side rendering, automatic code splitting, routing, and API routes, making it an excellent choice for building modern web applications.

Prerequisites

Before getting started with the Next.js application, ensure the following prerequisites are met:

  • Node.js 18.17 or later.

  • The application is compatible with macOS, Windows, and Linux operating systems.

Create a Next.js application

To create a new Next.js application, use one of the commands that are specific to either NPM or Yarn.

npx create-next-app@latest
yarn create next-app

Using one of the above commands will lead you to set up additional configurations for the project as below:

1.Define the project name: Users can specify the name of the project directly. Let’s specify the name of the project as ej2-nextjs-circular-gauge.

 What is your project named? » ej2-nextjs-circular-gauge

2.Select the required packages.

 What is your project named? ... ej2-nextjs-circular-gauge
 Would you like to use TypeScript? ... No / `Yes`
 Would you like to use ESLint? ... No / `Yes`
 Would you like to use Tailwind CSS? ... `No` / Yes
 Would you like to use `src/` directory? ... No / `Yes`
 Would you like to use App Router? (recommended) ... No / `Yes`
 Would you like to customize the default import alias? ... `No`/ Yes
Creating a new Next.js app in D:\ej2-nextjs-circular-gauge.

3.Once complete the above mentioned steps to create ej2-nextjs-circular-gauge, navigate to the directory using the below command:

cd ej2-nextjs-circular-gauge

The application is ready to run with default settings. Now, let’s add Syncfusion® components to the project.

Install Syncfusion® React packages

Syncfusion® React component packages are available at npmjs.com. To use Syncfusion® React components in the project, install the corresponding npm package.

Here, the React Circular Gauge component is used as an example. To install the React Circular Gauge component in the project, use the following command:

npm install @syncfusion/ej2-react-circulargauge --save
yarn add @syncfusion/ej2-react-circulargauge

Add Syncfusion® React component

Follow the below steps to add the React Circular gauge components to the Next.js project:

1.Define the Circular gauge component in the src/app/page.tsx file, as shown below:

'use client'
import { CircularGaugeComponent, AxesDirective, AxisDirective, PointersDirective, PointerDirective } from '@syncfusion/ej2-react-circulargauge';
export function App() {
  return(
  <CircularGaugeComponent >
    <AxesDirective>
      <AxisDirective>
        <PointersDirective>
          <PointerDirective value={35}></PointerDirective>
        </PointersDirective>
      </AxisDirective>
    </AxesDirective>
  </CircularGaugeComponent>);
}
export default App;

Run the application

To run the application, use the following command:

npm run dev
yarn run dev

To learn more about the functionality of the Circular Gauge component, refer to the documentation.

View the NEXT.js Circular Gauge sample in the GitHub repository.