Guides

Building Admin Pages

Intermediate~12 min

Create full-page React admin interfaces inside wp-admin. No iframe, native WordPress integration.

Declare Admin Page

Set "admin.page": true in your module.json to tell the Hub your module needs an admin page. The Hub registers the menu item and enqueues your assets automatically.

module.json (partial)
{
  "slug": "dashboard",
  "admin": {
    "page": true,
    "menu_title": "Dashboard",
    "menu_icon": "dashicons-chart-area",
    "position": 30
  }
}

React Entry Point

Place your React app in assets/admin.tsx. The Hub takeover system mounts it in a full-page container inside wp-admin — no iframe, full CSS control, access to the WordPress REST API.

assets/admin.tsx
import { createRoot } from 'react-dom/client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { App } from './components/app';

const queryClient = new QueryClient();

const root = createRoot(
  document.getElementById('meteorack-module-root')!
);

root.render(
  <QueryClientProvider client={queryClient}>
    <App />
  </QueryClientProvider>
);

Vite Build

Use Vite to build your React app. The Hub expects compiled assets in assets/dist/. Add a vite.config.ts at your module root.

vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
  build: {
    outDir: 'assets/dist',
    rollupOptions: {
      input: 'assets/admin.tsx',
      output: {
        entryFileNames: 'admin.js',
        assetFileNames: 'admin.css',
      },
    },
  },
});