What you will build
A reusable React component that embeds the assistant directly in your application. The component provides:- A floating widget that opens a chat panel when clicked
- Real-time streaming responses based on information from your documentation
Prerequisites
- Mintlify Pro or Custom plan
- Your domain name, which appears at the end of your dashboard URL. For example, if your dashboard URL is
https://dashboard.mintlify.com/org-name/domain-name, your domain name isdomain-name - An assistant API key
- Node.js v18 or higher and npm installed
- Basic React knowledge
- Existing React application (Next.js, Vite, Create React App, or similar). This guide uses a Vite application
Get your assistant API key
- Navigate to the API keys page in your dashboard.
- Click Create Assistant API Key.
- Copy the assistant API key (starts with
mint_dsc_) and save it securely.
The assistant API key is a public token that can be used in frontend code. Calls using this token count toward your plan’s message allowance and can incur overages.
Build the widget
1
Install dependencies
Install the AI SDK for React and a Markdown renderer:
2
Create the assistant component
Create a new file
AssistantWidget.jsx (or .tsx if using TypeScript) in your components directory:AssistantWidget.jsx
3
Configure environment variables
Add your assistant API token to your Restart your development server to apply the changes.
.env file in your project root:.env
Vite requires environment variables to be prefixed with
VITE_. Use the appropriate prefix for your framework.4
Add the widget to your app
Import and render the component in your application. Pass your Mintlify project
domain (the end of your dashboard URL. For example, domain-name from https://dashboard.mintlify.com/org-name/domain-name).App.jsx
5
Test the widget
- Start your development server:
- Open your application in a browser.
- Click the “Ask” button in the bottom-right corner.
- Ask a question about your documentation.
Customization ideas
This example shows a simple implementation of the assistant API. Here are some ways to begin customizing the widget.Add color customization
Accept color props and use them for theming:Add widget positioning options
Let users position the widget in different corners:Source citations
Extract and display sources from assistant responses:Troubleshooting
Widget not appearing
Widget not appearing
- Verify the component is imported and rendered in your app.
- Check that Tailwind CSS or your styling solution is properly configured.
- Ensure the z-index values do not conflict with other fixed elements.
401 authentication error
401 authentication error
- Verify your API token starts with
mint_dsc_. - Check the token is correctly set in your environment variables.
- Confirm you are using the public assistant API token, not the admin API key.
- Restart your development server after adding environment variables.
No responses from assistant
No responses from assistant
- Verify your project domain is correct.
- Check that your Mintlify plan includes the assistant feature.
- Confirm your documentation site is published and accessible.
- Verify the assistant API token is correctly set in your environment variables.
Debugging with browser console
Debugging with browser console
Open developer tools and check the Network tab to troubleshoot:
- Look for 401 or 403 authentication errors
- Verify API requests are reaching
https://api-dsc.mintlify.com/v1/assistant/{domain}/message - Check the response status and error messages