Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Migration from cmdk

ABCrimson edited this page Mar 7, 2026 · 2 revisions

Migration from cmdk

Automated Migration

The @crimson_dev/command-codemod package provides 4 jscodeshift transforms:

pnpm add -D @crimson_dev/command-codemod
# Run all transforms
npx command-codemod import-rewrite "src/**/*.tsx"
npx command-codemod data-attrs "src/**/*.tsx"
npx command-codemod forward-ref "src/**/*.tsx"
npx command-codemod should-filter "src/**/*.tsx"

--dry-run

Preview changes without writing files:

npx command-codemod import-rewrite "src/**/*.tsx" --dry-run

Transform Details

1. import-rewrite

- import { Command } from 'cmdk'
+ import { Command } from '@crimson_dev/command-react'

Handles: named imports, default imports, export * from, import(), require().

2. data-attrs

- <div cmdk-root="" />
+ <div data-command="" />
- querySelector('[cmdk-item]')
+ querySelector('[data-command-item]')

Full mapping: cmdk-rootdata-command, cmdk-inputdata-command-input, cmdk-listdata-command-list, cmdk-itemdata-command-item, cmdk-groupdata-command-group, cmdk-separatordata-command-separator, cmdk-emptydata-command-empty, cmdk-loadingdata-command-loading.

CSS variables: --cmdk-list-height--command-list-height.

3. forward-ref

- const MyComponent = React.forwardRef<HTMLDivElement, Props>((props, ref) => {
- return <div ref={ref} {...props} />;
- });
+ const MyComponent = ({ ref, ...props }: Props & { ref?: React.Ref<HTMLDivElement> }) => {
+ return <div ref={ref} {...props} />;
+ };

React 19 no longer needs forwardRefref is a normal prop.

4. should-filter

- <Command shouldFilter={false}>
+ <Command filter={false}>

shouldFilter={true} and bare shouldFilter are removed (filter defaults to true).

Breaking Changes

cmdk @crimson_dev/command-react
import { Command } from 'cmdk' import { Command } from '@crimson_dev/command-react'
[cmdk-item] [data-command-item]
--cmdk-list-height --command-list-height
React.forwardRef ref as prop
shouldFilter filter
React 18 React 19+ required

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /