What are On-Device Addons?
Unlike web Storybook addons that run in a browser, on-device addons are specially designed for React Native and render natively on iOS and Android devices. They provide essential functionality like:- Dynamic prop editing without code changes
- Event logging for component interactions
- Background color switching
- Documentation display within your app
Available Addons
Controls
Edit component props dynamically via a graphical UI
Actions
Log and monitor component events and interactions
Backgrounds
Change story background colors on the fly
Notes
Add markdown documentation to your stories
Installing Addons
Each addon is published as a separate npm package under the@storybook/addon-ondevice-* namespace. Install the addons you need:
Configuration
Register addons in your.rnstorybook/main.ts configuration file:
.rnstorybook/main.ts
The order of addons in the array determines the order of their panels in the Storybook UI.
Addon Options
Some addons accept configuration options. Use object notation to provide options:.rnstorybook/main.ts
Using Addons in Stories
Addons are configured through story parameters and metadata. Here’s a complete example:Button.stories.tsx
Compatibility with Web Addons
While on-device addons share similar APIs with their web counterparts, they are separate implementations optimized for React Native:| Web Addon | React Native Equivalent |
|---|---|
@storybook/addon-controls | @storybook/addon-ondevice-controls |
@storybook/addon-actions | @storybook/addon-ondevice-actions |
@storybook/addon-backgrounds | @storybook/addon-ondevice-backgrounds |
@storybook/addon-notes | @storybook/addon-ondevice-notes |
Web Storybook documentation can be helpful as a reference, but always verify that features are supported in the React Native version.
Next Steps
Controls Addon
Learn how to dynamically edit component props
Actions Addon
Discover how to log component events