Lifecycle
When a command is opened in Raycast, the command code is executed right away. If the extension exports a default function, this function will automatically be called. If you return a React component in the exported default function, it will automatically be rendered as root component. For command that don't need their own user interface (mode property set to "no-view" in the manifest), you can export an async function and perform API methods using async/await.
1
// Returns the main React component for a view command
2
export default function Command() {
3
return <Detail markdown="# Hello" />
4
}
Copied!
1
// Runs async. code in a non-view command
2
export default async () => {
3
await showHUD("Hello")
4
}
Copied!
You can inspect the Environment for extension information and paths or access Preference Properties for user-entered values that are passed to the command.
When the command is unloaded (typically by popping back to root search for view commands or after the script finished for non-view commands), Raycast unloads the entire command from memory. Note that there are memory limits for a command and if those limits are exceeded the command gets terminated and users will see an error message.
Last modified 8d ago
Copy link