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 Scheduler component, install the @syncfusion/react-Scheduler 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 Scheduler component:
1.Import the Scheduler component in app/page.tsx:
2.Add the Scheduler component to the application. To display events in the Scheduler, import a structured JSON dataset and store it in React state, then assign this data to the eventSettings property. The Scheduler will render these events across Day, Week, Work Week, and Month views.
Run the application
Start the application with:
The output will appear as follows:
To learn more about the functionality of the Scheduler component, refer to the documentation.