Introduction
React continues to be one of the most popular frameworks for building interactive dashboards. With React 18's concurrent features, the rise of Vite as the build tool of choice, and modern TypeScript integration, creating dashboards in React is now more powerful and developer-friendly than ever.
This comprehensive guide walks you through creating dashboards in React using modern 2025 practices, then shows you how to supercharge your dashboards with Databrain's embedded analytics platform.
What you'll build:
- A modern React dashboard with Vite and TypeScript
- Integration with Databrain for production-ready analytics
Prerequisites:
- Node.js 20+ and npm 10+
- Basic React knowledge
- Familiarity with TypeScript (recommended)
Without Databrain: How to Create a Dashboard in React
Let's start by building a custom dashboard from scratch to understand the fundamentals.
Create a React App:
In 2025, Vite has replaced Create React App as the standard tool for React applications. Vite offers significantly faster development experience and better production builds.
Run the following command in your terminal: npx create-react-app my-app.
This command sets up a new React application called "my-app" and generates all the necessary files and folder structure for you.
Why Vite in 2025?
- 10-100x faster than Create React App
- Native ESM (no bundling during development)
- TypeScript support out of the box
- Optimized production builds
- Hot Module Replacement that works instantly
Clean Up App.tsx and App.css:
In your project folder, you'll find two important files: App.tsx and App.css
These files contain initial code for your React application. You should remove any code that you don't need to keep your project clean and organized.
src/App.css:
Remove all existing styles - we'll add our own as we build
Install Styling Library
Instead of Bootstrap, we'll use Tailwind CSS which has become the industry standard for React applications in 2025. It provides better performance, smaller bundle sizes, and more flexibility.
To use Tailwind CSS in your React app, you can install it by running:
This command downloads and adds the Tailwind CSS library to your project, allowing you to easily style your components.
Configure Tailwind CSS:
Update `tailwind.config.js`:
Update src/index.css:
Create a Components Folder:
To keep your project organized, create a folder named "components" inside the "src" folder.
This "components" folder will house all the custom React components you'll create for your app.
Run this command : mkdir src/components
Create a Navbar Component:
Inside the components folder, create a sub-folder named Navbar
In the Navbar folder, create two files: Navbar.tsx and Navbar.css
The Navbar.tsx file will hold the TypeScript/JSX code for your Navbar component, while the Navbar.css file will contain the styling for the Navbar.
Each component follows the same structure for uniformity across the code. Each component has two files: index.js and index.css. This helps keep things organized and easy to work with, making it clear where the component's code and styling can be found.
src/components/Navbar/Navbar.tsx:
src/components/Navbar/Navbar.css:
The Navbar will look like a vertical sidebar with interactive menu items. The Navbar will look like this:

Install Icons Library
For better icons, let's install React Icons which provides Font Awesome and many other icon sets:
Run this command : npm install react-icons
Why React Icons in 2025?
- Tree-shakeable (only imports icons you use)
- TypeScript support built-in
- Includes Font Awesome, Material Icons, and more
- No CSS files needed
You can now use icons in your components:
Header Component
The Header component will contain a search bar, notifications, and user profile section.
src/components/Header/Header.tsx:
src/components/Header/Header.css:
This code defines a React functional component called Header, creating a header section with a search input field, a notification bell icon with a badge, and a profile icon, styled with modern CSS.

Courses Component:
Now let's create a component to display course metrics. This demonstrates how to work with props and dynamic data.
src/components/Courses/Courses.tsx:
src/components/Courses/Courses.css:
In the above code, the color information is dynamically passed down from the parent component through the courses array and is subsequently applied to style the card. This approach allows for adaptable and flexible color rendering based on the provided data.
This approach allows for adaptable and flexible color rendering based on the provided data.

Course List Component:
This component displays a table of courses with their status.
src/components/CourseList/CourseList.tsx:
src/components/CourseList/CourseList.css:
This code defines a React component named CourseList that displays a list of courses. It uses an array called courseData to hold information about each course, such as the title, level, date, and status. The status text color is dynamically determined based on the course's completion status, and the list is presented in a modern table format.
The status text color is dynamically determined based on the course's completion status, and the list is presented in a table format.

Putting It All Together
Now let's update our main App component to use all the components we've created.
src/App.tsx:
src/App.css:
Final Steps
We've assembled all the components, and now it's time to launch the live dashboard by running:
"npm run dev"
Visit http://localhost:5173 in your browser to see your dashboard in action!
The dashboard will feature:
- A fixed sidebar with navigation
- A sticky header with search and notifications
- Metric cards showing course statistics
- A detailed course list table with status indicators
What makes this 2025 approach better:
- Vite provides instant hot module replacement
- TypeScript ensures type safety and better developer experience
- Modern CSS with proper component encapsulation
- React 18 concurrent features available
- Tree-shaking eliminates unused code in production
- Optimized builds with automatic code splitting

Alternate Solution: With Databrain - Create React Dashboards in Minutes
Building a custom dashboard is great for learning, but production dashboards require significantly more features. This is where Databrain becomes valuable.
Connect to Your Database and Create a Dashboard
Databrain offers support for a range of databases, including PostgreSQL, MySQL, MongoDB, Snowflake, BigQuery, and 100+ more data sources.
In this guide, we'll walk you through the complete process step by step.
Step 1: Connect to Your Database
Before integrating Databrain into your React app, you need to set up your data source in the Databrain platform.
Connecting Your Data Source:
- Sign up at Databrain
- Create a workspace for your project
- Go to "Data Sources" section
- Click "Add New Datasource" button
- Select your database type (e.g., MongoDB, PostgreSQL, MySQL)
For MongoDB Example:
When you activate the MongoDB BI Connector, it serves as an interface connecting MongoDB and Databrain. Activating the instance will make it easier to understand and use your MongoDB information for smarter decision-making.
Connection Details:
- Choose the database you want to connect to (e.g., workspace name: "Demo workspace")
- In the "Name" field, give your connection a descriptive name
- Specify the host (IP address or domain name) where your database is running
- Set the port (usually 3306 for MongoDB BI Connector, but check your configuration)
- Enter the username and password for your database cluster
- Click "Test Connection" to verify
- Click "Save" to store your connection
Supported Data Sources (100+):
- SQL Databases: PostgreSQL, MySQL, SQL Server, MariaDB
- Cloud Data Warehouses: Snowflake, BigQuery, Redshift, Azure Synapse
- NoSQL: MongoDB, DynamoDB, Cassandra
- Analytics: ClickHouse, DuckDB, Druid
- Query Engines: Trino, Presto, Athena
- APIs: REST APIs, GraphQL
- And many more...
Step 2: Create a Dashboard
Once your data source is connected, create your dashboard:
- Click "Create New Workspace" button (with a plus icon) in the top right corner
- Enter the workspace name and description
- Click "Save" to create the workspace
- Click "Create a New Dashboard"
- Fill in the dashboard name (e.g., "React Analytics Dashboard")
- Enter a unique dashboard ID (e.g., "react-dashboard") - you'll use this later for integration
- Click "Save" to create your dashboard
Step 3: Design a Metric
1. Click "Create Metric" in the top right corner
2. Select the dataset from your connected data source
3. Choose your data fields:
- Drag and drop data into rows and columns
- For example: Select "Public" > "Users" and choose "id," "name," "email" for columns
4. Choose the chart type:
- Table
- Bar Chart
- Line Chart
- Pie Chart
- And 50+ more options
5. Customize your metric:
- Add filters (date ranges, categories, etc.)
- Set aggregations (SUM, AVG, COUNT, etc.)
- Customize colors and styling
- Add drill-downs and interactivity
6. Click "Save to Dashboard"
7. Enter a unique metric ID (e.g., "user-table")
Create as many metrics as you need by repeating this process. You can create:
- KPI cards showing single values
- Time-series charts for trends
- Tables for detailed data
- Heatmaps for correlations
And much more...
Integrating with Your App
Now let's integrate your Databrain dashboard into your React application.
Step 4: Setup Your React App for Databrain
If you already have a React app from the previous section, great! If not, create one:
Clean and Organize Your App
After removing unnecessary files, your folder structure will look like this:
Remove all code from App.css and simplify App.tsx:
Step 5: Integrate Databrain
Now let's install and integrate the Databrain package.
Install Databrain Package:
Create Environment Variables:
Create a `.env` file in your project root to store your Databrain credentials securely:
Important:
- Never commit your `.env` file to git
- Add `.env` to your `.gitignore` file
- Get your token from Databrain's Share menu
For a Dashboard:
A dashboard consists of various metrics put together. To integrate the entire dashboard, use the following code:
src/App.tsx:
src/App.css:
For Individual Metrics:
If you want to integrate only specific metrics instead of the entire dashboard:
Getting Your Token and Dashboard ID:
1. Go to your dashboard in Databrain
2. Click the "Share" button (located near Create Metric)
3. Copy your token and dashboard ID
4. Paste them into your `.env` file
Run Your Application:
After this, visit `http://localhost:5173` and you will see the dashboard live and running in your browser!
What you get out of the box:
- Real-time data updates
- Interactive filtering and drill-downs
- Export to CSV/PDF
- Email scheduling
- Mobile responsive
- 50+ chart types
- Role-based access control
- Multi-tenant support
Step 6: Customize Your Dashboard
Once you've integrated Databrain into your React app and have your dashboard set up, you can customize it to fit your needs.
Tweak the Dashboard
Customizing your dashboard lets you tailor it to your specific needs and preferences. Here are examples of customization you can do:
1. Customize Layout: You can arrange the metrics and components on your dashboard by dragging and dropping them in the Databrain interface. You can also resize and rearrange them to create a visually appealing layout.
2. Add More Metrics: To add metrics, click on the "Add Metric" button in Databrain, and select the dataset and data points you want to display. You can choose different chart types, like tables, charts, or graphs, based on your data and visualization preferences.
3. Data Filtering: You can add filters to the metrics to allow users to interact with the data dynamically. These filters can be based on various attributes or dimensions of your data.
Example with filters in your React app:
4. Styling:
5. Interactivity:
Set up interactions between different components on your dashboard. For example, you can create drill-downs, tooltips, or pop-ups to provide more information when users interact with the dashboard.
Step 7: Make Your Dashboard Accessible
Domain Whitelisting
To display the Databrain dashboard correctly on your website, you need to whitelist your domain:
1. Go to the 'Settings' section in Databrain
2. Find 'Embed Settings' and click on it
3. Select 'Whitelist Domains'
4. Paste your website's domain into the 'Allowed Origins' field
5. Click the 'Add' button
By following these steps, you'll ensure that the dashboard integrates seamlessly with your React app.
User Permission
You can control who can access and modify the dashboard:
- Current User: Only you can see and edit the dashboard
- All Users: Everyone in your workspace can access the dashboard
- Custom Permissions: Set up role-based access control for specific users or groups
Manual Dashboard vs Databrain Comparision
Deployment Checklist
- Replace demo tokens with production tokens
- Set up environment variables properly
- Add `.env` to `.gitignore`
- Enable code splitting for Databrain component
- Add error boundaries
- Test on mobile devices
- Verify all data sources are connected
- Configure user permissions in Databrain
- Set up domain whitelisting
- Test loading states and error states
- Optimize bundle size
- Enable production build optimizations.
Conclusion
You now have two powerful approaches for building React dashboards:
- Custom Dashboard - Perfect for learning React and simple use cases
- Databrain Integration - Production-ready analytics in hours instead of months
When to Use Each:
Build Custom:
- Learning React fundamentals
- Simple, static dashboards
- Full control over every detail
Use Databrain:
- Production SaaS applications
- Customer-facing analytics
- Multi-tenant architectures
- Need 50+ chart types
- Require RBAC and security
- Time-to-market is critical
Hybrid Approach (Recommended):
Most successful teams use both:
- Databrain for complex analytics, reporting, and customer-facing dashboards
- Custom components for simple metrics and app-specific UI
Next Step
- Start your free Databrain trial: https://www.usedatabrain.com
- View React integration docs
- Contact support: support@usedatabrain.com
- Watch video tutorials: https://www.youtube.com/@usedatabrain
Resources and Documentation
- React Documentation: https://react.dev
- Vite Documentation: https://vitejs.dev
- TypeScript Handbook: https://www.typescriptlang.org/docs/
- Databrain Documentation: https://docs.usedatabrain.com
- React Icons: https://react-icons.github.io/react-icons/


.png)
.png)



