Learn to build a high-performance, SPA-style Admin Dashboard in WordPress using React. Master client-side routing and data-heavy UI tables for your plugin.
Previously in this course, we covered Code Splitting and Lazy Loading for WordPress React Plugins. Now that we can efficiently bundle our assets, it's time to build the primary interface for our Knowledge Base plugin: a full-featured, Single-Page Application (SPA) admin dashboard.
In a standard WordPress admin, every click triggers a full page reload. This is a massive UX bottleneck for data-heavy plugins. By adopting an SPA approach—where the server delivers one entry point and JavaScript handles the navigation—we provide a fluid, desktop-like experience.
We aren't just building a static page; we are building an application that manages persistent state, performs asynchronous data fetching, and handles complex UI updates without flickering.
Since we are inside the WordPress Admin, we don't need a heavy library like react-router-dom unless our needs are extreme. Instead, we can use the MemoryRouter pattern or a simple switch statement based on a state variable to handle views. For most plugin dashboards, a state-based router is safer and keeps our bundle size minimal.
Here is how we set up our root dashboard component to manage views:
JSXimport React, { useState } from CE9178">'react'; import { KBTable } from CE9178">'./components/KBTable'; import { KBEditor } from CE9178">'./components/KBEditor'; export const AdminDashboard = () => { const [view, setView] = useState(CE9178">'list'); // CE9178">'list' | CE9178">'edit' const [activeId, setActiveId] = useState(null); const navigate = (to, id = null) => { setActiveId(id); setView(to); }; return ( <div className="kb-dashboard-root"> <nav> <button onClick={() => navigate(CE9178">'list')}>All Articles</button> </nav> <main> {view === CE9178">'list' && <KBTable onEdit={(id) => navigate(CE9178">'edit', id)} />} {view === CE9178">'edit' && <KBEditor id={activeId} onBack={() => navigate(CE9178">'list')} />} </main> </div> ); };
When dealing with a "data-heavy" interface, the primary enemy is re-render performance. If you have 100+ knowledge base articles, a poorly optimized table will lag every time you type in a search filter.
We use the @wordpress/components library for UI consistency, but we must wrap our data-fetching logic in a custom hook to keep our components clean.
We want to ensure that our table only updates when the underlying data changes, not every time the parent component re-renders.
JSXimport { Table, TableRow, TableCell } from CE9178">'@wordpress/components'; import { useKBData } from CE9178">'../hooks/useKBData'; // Custom hook export const KBTable = ({ onEdit }) => { const { articles, isLoading } = useKBData(); if (isLoading) return <div>Loading articles...</div>; return ( <table className="wp-list-table widefat fixed striped"> <thead> <tr> <th>Title</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tbody> {articles.map((article) => ( <tr key={article.id}> <td>{article.title}</td> <td>{article.status}</td> <td> <button onClick={() => onEdit(article.id)}>Edit</button> </td> </tr> ))} </tbody> </table> ); };
useState hook in your main App.jsx to switch between a DashboardHome view and an ArticleEditor view.useEffect inside your KBTable component to fetch your Knowledge Base items from the REST API endpoint you built in our previous lesson.React.memo to ensure that only the row being edited or deleted re-renders during state transitions.react-router-dom unless you absolutely need deep-linking (URL-based state). It often conflicts with WordPress's own routing and bloats your bundle.Building an Admin Dashboard with React requires a shift in mindset: treat the dashboard as an application, not a collection of pages. By implementing client-side routing, you provide a snappy UX that makes your plugin feel like a professional SaaS tool rather than a standard WordPress plugin. Always prioritize render performance in your tables, as this is where users spend the most time interacting with your data.
Up next: We will move into Component Library Design to ensure our dashboard components are reusable and maintainable.
Master WordPress Data management. Learn to create custom stores, implement selectors and actions, and orchestrate global state across your blocks.
Read moreLearn to build a safe, user-centric Modal confirmation system in your WordPress React admin UI to prevent accidental data loss during API operations.
Advanced Admin Dashboards
Custom Hooks for React