A working example of embedding the Mintlify assistant widget into a Vite app. This example demonstrates how to integrate the assistant via the API.
See Tutorial: Build an in-app documentation assistant or step-by-step instructions to embed and customize the widget.
-
Install dependencies:
npm install
-
Copy
.env.exampleto.envand add your Mintlify assistant API token:cp .env.example .env
Edit
.envand replacemint_dsc_your_token_herewith your actual token from the Mintlify dashboard. -
Update
src/config.jswith your Mintlify project details:- Replace
domain: 'your-domain'with your project domain (the last part of your dashboard URLhttps://dashboard.mintlify.com/org-name/your-domain). - Replace
docsURL: 'https://yourdocs.mintlify.app'with your documentation site URL.
- Replace
-
Start the development server:
npm run dev
-
Open the URL shown in your terminal (usually
http://localhost:5173)
- Click the "Ask" button to open the assistant widget.
- Ask a question about your documentation.
src/
├── App.css # App styles
├── App.jsx # Main app component
├── config.js # Configuration (domain and docsURL)
├── index.css # Global styles
├── main.jsx # React entry point
├── utils.js # Helper functions for parsing suggestions and extracting sources
└── components/
├── AssistantWidget.jsx # Main widget component with chat state and API logic
└── Message.jsx # Individual message component for rendering user and assistant messages
src/config.js- Update your Mintlify project domain and documentation URLsrc/components/AssistantWidget.jsx- Customize widget styling or behavior.env- Add your assistant API token (not committed to git)