Getting Started with a Vite App using React Components

This guide outlines how to set up a Vite project within a TypeScript environment and integrate Syncfusion® React components.

Vite is a build tool and development server for modern web projects. It supports cutting-edge web technologies like ES modules, TypeScript, JSX, and CSS modules. Vite's development server leverages native ES modules in modern browsers, ensuring rapid startup and quick feedback during development.

Prerequisites

System requirements for Syncfusion® React UI components

Create a Vite project

To create a new Vite project, use either NPM or Yarn.

Executing one of the above commands will guide you through additional configuration steps:

1. Specify the project name. For this guide, we'll use my-project.

2. Select React as the framework, which will set up a React project.

3. Choose TypeScript as the framework variant to build this Vite project with Typescript and React.

4. Choose not to use the experimental bundler and skip automatic npm install & start.

5. After setting up my-project, install its dependencies:

Now that my-project is ready to run with default settings, 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

Import themes for our React components using CSS or SASS from npm packages. For details on built-in themes and usage, refer to the themes topic.

In this guide, we apply the Material theme with CSS styles in the src/App.css file:

Ensure CSS styles are imported in the correct dependency order.

Add Syncfusion® React component

Follow these steps to add the React Message component to the Vite project:

  1. Import the Message component in src/App.tsx:
  1. Then, add the Message component in the application using the following code sample.

Run the project

Execute the following command to run the project:

The output will appear as follows:

See also