-
Notifications
You must be signed in to change notification settings - Fork 0
SSR and Next.js
ABCrimson edited this page Mar 11, 2026
·
2 revisions
modern-cmdk/react works with server-side rendering. All components have "use client" directives.
// app/components/command-palette.tsx
'use client';
import { Command } from 'modern-cmdk/react';
export function CommandPalette() {
return (
<Command.Dialog>
<Command.Input placeholder="Search..." />
<Command.List>
<Command.Empty>No results.</Command.Empty>
<Command.Item>Settings</Command.Item>
</Command.List>
</Command.Dialog>
);
}The WASM engine is browser-only. Use dynamic imports:
'use client';
import { useEffect, useState } from 'react';
import type { SearchEngine } from 'modern-cmdk';
function useWasmSearch() {
const [engine, setEngine] = useState<SearchEngine | null>(null);
useEffect(() => {
import('modern-cmdk-search-wasm')
.then(({ createWasmSearchEngine }) => createWasmSearchEngine())
.then(setEngine);
}, []);
return engine;
}- All components export
"use client"— safe in RSC environments - The core state machine is isomorphic (no DOM dependency)
- WASM engine must be loaded client-side only
- CSS imports work with Next.js CSS module system