Menu

I got tired of clicking through my app to check one component, so I built a Vite plugin for itVitrine: add /** @preview */ above a component and see it in a gallery on your own Vite dev server

Reddit r/reactjs·u/yuntaengtaeng·17 days ago
#28MTz5D9
#preview#vitrine#vite#component#plugin
Reading 0:00
15s threshold

A lot of my day as a React developer was: build a component, open the app, click through to the screen where it shows up, check it, change something, repeat. Checking an error state or a long message meant recreating that state by hand every time.

So I built Vitrine , a Vite plugin. You put a comment above an exported component:

/** @preview */ export const PrimaryButton = () => Save ;

and open `/__vitrine` on the Vite dev server you already run. Setup is one line next to your React plugin:

plugins: [react(), vitrine()]

The idea came from Jetpack Compose's `@Preview`: write only the cases you care about, right next to the code. Since previews go through your own dev server, aliases, CSS, plugins and HMR work exactly like in your app.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.