-
Notifications
You must be signed in to change notification settings - Fork 0
SSR and Next.js
ABCrimson edited this page Mar 7, 2026
·
2 revisions
@crimson_dev/command-react works with server-side rendering. All components have "use client" directives.
// app/components/command-palette.tsx 'use client'; import { Command } from '@crimson_dev/command-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 '@crimson_dev/command'; function useWasmSearch() { const [engine, setEngine] = useState<SearchEngine | null>(null); useEffect(() => { import('@crimson_dev/command-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