Getting Started with a Next.js App using React Components

This guide walks you through setting up a Next.js application and integrating Syncfusion® React components.

What is Next.js?

Next.js is a React framework that simplifies building fast, SEO-friendly, and user-centric web applications. It offers features like server-side rendering, automatic code splitting, routing, and API routes, making it ideal for modern web applications.

Prerequisites

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

  • Node.js 18.17 or higher.

  • Compatibility with macOS, Windows, or Linux.

Create a Next.js application

To create a new Next.js app, use either an NPM or Yarn command:

After running the command, you'll be prompted to configure the project:

1.Define the project name: Let's specify the name of the project as nextjs-demo.

2.Select the required packages.

3.Once set up, navigate to the project directory:

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

Install Syncfusion® React packages

Syncfusion® React components are available on npmjs.com. To use the React Message component, install the @syncfusion/react-notifications package:

Import Syncfusion® CSS styles

Syncfusion® React components are styled using built-in themes. Import the Material theme into app/globals.css, and remove the existing styles in that file:

For more on themes and individual component CSS, see the themes section.

Add Syncfusion® React component

To integrate the React Message component:

1.Import the Message component in app/page.tsx:

2.Then, add the Message component in the application using the following code sample.

Run the application

Start the application with:

The output will appear as follows:

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

See also