Pulling screens into an app

Docs

add --screen writes a screen made in the workbench into your app as plain files you own: the screen, its sample data and the parts it is built from. The kit components it needs come along, so the screen renders as it does in the preview.

How to use it

In the workbench, open a screen and press Add to app; it shows the command with the screen's file name. Run it in your app's folder:

npx designsource add --screen customers

--screen is repeatable and takes a comma-separated list (--screen customers,invoices); --screen all pulls every screen of the project. It needs Pro on the project owner's account, like the rest of add. A run with only --screen takes the components the screens need without asking and writes no /design-system section of its own; in an app that already has the section, a run with --screen (shell included) also refreshes the section and every kit component, as a bare rerun does. It still asks before replacing a file designsource did not write or you edited.

Files land under the app's components folder:

  • screens/<name>.tsx, the screen, and screens/<name>.data.ts, its sample data.
  • screens/parts/, the shared parts (page header, table, form and so on) that screens import.
  • Any kit component it uses that your app lacks, under components/ui.

add prints an import line per screen and never adds routes. In a Next.js App Router app, mount a screen with a route file:

// app/customers/page.tsx
export { CustomersScreen as default } from '@/components/screens/customers'

In Vite, or anywhere else, render the screen's component where you want it. Swap the sample data for your own in <name>.data.ts.

If the app has the /design-system section, every screen pulled into it opens there too, in the section's Screens view at /design-system/screens (Vite: /design-system.html#/screens), without mounting it anywhere. The view follows the screens in your app: a rerun after every screen is gone empties it.

Links between screens. A pulled screen links to another at /<name>, so mount each linked screen's route. In a create app the links go to /app/<name> (the home page to /, other pages to /<name>). In the /design-system section they open the section's own page for that screen, which needs designsource 0.12.0 or later; an older CLI points them at /<name>. In the app shell, the site menu and the section, a link to a screen that is not in the app does nothing. They come from the shared part screens/parts/screen-links.tsx; once you edit it, the shells and the section stop providing links, and screens link to /<name> again.

--screen shell writes screens/app-shell.tsx: a sidebar with the project name and one link per screen in the app, to /<name>. It adds no routes: mount each screen on a route of that name yourself. Wrap your pages in it (add prints the AppShell import line). A bare rerun refreshes it. With no screen yet, add says The app shell lists no screens yet: each one you add with designsource add --screen joins its menu. If the kit has no sidebar or icons component, add prints Skipped the app shell: the kit from this DS source server has no <component>. and carries on.

Pages. A marketing page, of any of the six kinds, is pulled by name too (--screen home), with site-links, site-frame and the motion library. --screen site writes screens/site-shell.tsx, a header and footer listing the pages in your app. Mount each page on its own route inside SiteShell, never the app shell. Reruns refresh the menu, add <names> excepted. designsource 0.19.0 asks for all six kinds and, against a server that knows only three, retries once for those. See Marketing pages.

If a page's hero shows one of your app screens, designsource 0.19.0 writes that screen too and says Also added <Title>, shown in <Page>'s hero. When that screen is skipped and not already in your app, the page is skipped as well. An older CLI gets the mock-up instead.

How it works

Each file starts with a stamp comment, as components do. Rerunning add refreshes the screens already in your app and keeps ones you edited (Kept your edits to …); --force replaces them. A screen DS source no longer has is left in place and named. Parts are shared: a part you edited whose kit version has changed since skips every screen using it until you pass --force; one whose kit version has not moved is kept. A screen and its data file move together: if you edited one and the kit has since changed the other, the screen is skipped and named, and --force replaces both; otherwise your edited file is kept and nothing else of that screen is rewritten.

A screen is pulled from its current version in the workbench.

Agents. A coding agent uses mcp: list_screens, get_screen_source, add_ui_kit with screens ("site" writes the page menu, never the app shell), and, signed in with login, generate_screen.

What can go wrong

  • No screen named "x" in <project>. Its screens: customers (Customers), …: the name is the file name, shown in the Add to app command and in the workbench's screen picker.
  • This DS source server does not send screens yet. Try again later, or run add without --screen.: a server older than your CLI.
  • A skipped screen, a version that can't be built and the other refusals are listed with their fixes in CLI errors.