logoAnt Design X

DesignDevelopmentComponentsPlayground
  • Ant Design X of React
  • Changelog
    v1.2.0
  • Basic Usage
    • Usage with create-react-app
    • Usage with Vite
    • Usage with Next.js
    • Usage with Umi
    • Usage with Rsbuild
  • Model Integration
    • OpenAI
      Updated
    • Qwen
      Updated
    • Others
  • Other
    • Contributing
    • dangerouslyApiKey Explanation
    • FAQ

Usage with Vite

Resources

Ant Design
Ant Design Charts
Ant Design Pro
Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Web3
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
Twitter
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

Here’s the translation of your guide on using @ant-design/x with Vite:


Vite is one of the best tools for React application development. This article will guide you on how to use @ant-design/x components in a Vite project and customize Vite's configuration to meet various engineering needs.

Installation and Initialization

Before you start, you might need to install yarn, pnpm, or bun.

npm iconnpm
yarn iconyarn
pnpm iconpnpm
Bun LogoBun
bash
$ npm create vite antdx-demo

The tool will automatically initialize a scaffold and install necessary dependencies for a React project. If you encounter network issues during the process, try configuring a proxy or using another npm registry.

Next, navigate to the project directory, install dependencies, and start the development server.

bash
$ cd antdx-demo
$ npm install
$ npm run dev

Visit http://localhost:5173/ in your browser, and seeing the Vite + React interface means the setup is successful.

Importing @ant-design/x

Here is the default directory structure generated by Vite.

├── public
│   └── vite.svg
├── src
│   └── assets
│ └── react.svg
│   ├── App.css
│   ├── App.js
│   ├── index.css
│   ├── main.js
│   └── logo.svg
├── index.html
├── package.json
└── vite.config.js

Now, install and import @ant-design/x using yarn, npm, pnpm, or bun.

npm iconnpm
yarn iconyarn
pnpm iconpnpm
Bun LogoBun
bash
$ npm install @ant-design/x --save

Modify src/App.js to import the Bubble component from @ant-design/x.

jsx
import React from 'react';
import { Bubble } from '@ant-design/x';
const App = () => (
<div className="App">
<Bubble content="Hello world!" />
</div>
);
export default App;

You should now see the Bubble component from @ant-design/x on your page. You can proceed to use other components to develop your application. For other development processes, you can refer to the official Vite documentation.

You have successfully integrated @ant-design/x components, so start developing your application!