import * as React from "react"; import Code from "../Code"; export default function Actions() { return (

Actions

When a user searches for something in kbar, the result is a list of ActionImpls. ActionImpls are a more complex, powerful representation of the action object literal that the user defines.

The way users register actions is by first passing a list of default action objects to KBarProvider, and subsequently using{" "} useRegisterActions to dynamic register actions.

The object looks like this:

any; parent?: ActionId; };`} />

kbar manages an internal state of action objects. We take the list of actions provided by the user and transform them under the hood into our own representation of these objects, ActionImpl.

You don't need to know too much of the specifics of{" "} ActionImpl – we transform what the user passes to us to add a few extra properties that are useful to kbar internally.

All you need to know is:

Actions can have nested actions, represented by parent{" "} above. With this, we can do things like building a folder-like experience where toggling one action leads to displaying a "nested" list of other actions.

Static, global actions

kbar takes an initial list of actions when instantiated. This initial list is considered a static/global list of actions. These actions exist on each page of your site.

Dynamic actions

While it is good to have a set of actions registered up front and available globally, sometimes you will want to have actions available only when on a specific page, or even when a specific component is mounted.

Actions can be registered at runtime using the{" "} useRegisterActions hook. This dynamically adds and removes actions based on where the hook lives.

); }