1 Install @preserve-sdk/react
Preserve runs on an SDK with a prebuilt component. To get started, add the SDK to your project using the following command. You can also use yarn or pnpm.2 Set your environment variables
Preserve uses both a publishable and secret key, both of which can be found in your dashboard under the API keys tab..env
3 Install the Preserve Provider
Preserve uses a provider that wraps your application to provide your instance’s context. See below examples for the app router or pages router.4 Add the Search component
The Search component can be installed anywhere in your application. It wraps a “trigger”, which when clicked will pop up the menu. This means you can style the trigger element however you’d like for the menu to pop up. In the example below, for instance, the “Open Search” button is the trigger element. The trigger can be multiple elements nested infinitely down.app/component-with-search.tsx
A list of custom callback functions for the command palette to access, where the keys correspond to those registered in the Dashboard under ‘Commands’.Example:
{ 'copy-api-key': copyApiKey, 'logout': handleLogout }An optional custom router function for those looking for native routing functionality, for example in an SPA (Single-Page Application).Example:
router={routerFunction}Sets whether this is a development instance of Preserve (displays ‘Drafts’ in the Command Menu), or a production instance (no drafts displayed).Example:
'dev' or 'prod'The theme for the command menu (light or dark). Defaults to light.Example:
'dark' or 'light'