Composify

repository·main·Indexed 42 days ago

https://github.com/composify-js/composify

A Server-Driven UI (SDUI) library for React that provides a visual editor and renderer. It allows non-developers to build and modify pages using an existing design system of production React components without requiring code deployments. The core workflow involves registering components in a Catalog, rendering JSX strings via the Renderer component, and visually composing layouts using the Editor component.

Tokens
24.2K
Snippets
76
Records
103
Agent score
50%

What's inside Composify

  1. What is the Catalog and how does it work?

    main

    The Catalog is the central registry for Composify. Both the editor and the renderer depend on it. Every component must be registered in the Catalog before it can be used in the editor or rendered correctly.

    Through the Catalog, you define:

    • Component availability in the editor
    • Prop specifications (what props are accepted)
    • Editor UI for props (how they are edited)
    • Metadata like categories and default values.

    Note on Unregistered Components: If you attempt to render a component that has not been registered via Catalog.register, Composify treats it as a React Fragment. The component will not render, and its props will be ignored, but the application will not crash.

    import { Catalog } from 'composify';
    
    // Components must be registered here to be usable
    Catalog.register('ComponentName', {
      component: MyComponent,
      props: { ... },
    });
  2. What is Server-Driven UI (SDUI) in Composify?

    main

    Composify implements a democratized version of Server-Driven UI. In this architecture, the server (or a remote configuration) decides which components are rendered and how they are composed, rather than the client having a hardcoded layout.

    This enables:

    • Instant UI updates: Change layouts and component combinations without redeploying your application.
    • Decoupled workflows: Allow non-engineers to manage content and layouts while engineers focus on building the underlying component library.
  3. Use Composify as a design tool with zero drift

    main

    Composify allows you to use your actual production code as a design canvas. Instead of creating static mockups or lookalike components that eventually drift from the real implementation, designers build using the exact same components used in the live application.

    This approach provides:

    • Zero drift: The design canvas is the production code.
    • Guaranteed consistency: Only components registered in your system can be used in the editor.
    • Creative freedom with guardrails: Designers work within the established boundaries of your actual UI stack.

    Workflow for new components:

    1. Designers identify a need for a new component.
    2. Engineers build and register the component in the system.
    3. The component becomes instantly available for use in the Composify editor.
  4. Achieve instant UI updates without redeployments

    main
    Composify allows you to move your UI definition from hard-coded client-side code to the server. Instead of shipping new JavaScript bundles or waiting for CI/CD pipelines and App Store reviews, you can send new JSX strings from your server to the client. The client-side renderer processes these updates, making UI changes (like banner titles or spacing adjustments) live instantly for all users the next time they open the app.
  5. Understand the core value of Composify

    main

    Composify is a Server-Driven UI (SDUI) solution designed to bridge the gap between code-based design systems and visual editing. Unlike traditional no-code tools that require you to abandon your code or rewrite components to fit a proprietary SDK, Composify works with your existing components.

    It allows engineering teams to provide 'building blocks' from their existing design system to non-technical users (like marketing or product teams), enabling them to compose layouts visually without requiring new code deployments.

  6. How Composify works: Register, Render, and Edit

    main

    Composify operates through a three-step workflow that bridges your existing component code with a visual interface:

    1. Register components: You define a Catalog that maps your production components to visual controls (like text inputs, toggles, or color pickers) so non-developers can manipulate their props.
    2. Standard rendering: The library uses a <Renderer /> component to parse JSX strings and render them using your framework's native runtime (e.g., createElement in React).
    3. Visual Editing: By passing the JSX source string to the <Editor /> component, the code transforms into an interactive tree where users can drag-and-drop components and modify props via a sidebar. Saving the changes serializes the tree back into a clean JSX string.

    This approach follows a Zero Rewrite philosophy: your component files (e.g., Button.tsx) remain standard components without vendor-specific props or wrappers. All editor-specific metadata is isolated in the Catalog configuration.

    // 1. The data is a standard JSX string
    const source = `
      <VStack gap={4}>
        <Text size="xl">Hello World</Text>
        <Button variant="primary">Click Me</Button>
      </VStack>
    `;
    
    // 2. Render it in your app
    <Renderer source={source} />
    
    // 3. Or use the Editor for visual manipulation
    <Editor source={source} />
  7. Enable drag-and-drop child components with the `children` prop

    main

    The children prop is a specialized version of the node property. By defining a prop named children with type: 'node', the property is hidden from the standard property panel. Instead, it enables a visual canvas feature where you can directly drop and arrange child components onto the canvas, mimicking standard React composition.

    Catalog.register('Sample', {
      component: Sample,
      props: {
        children: {
          label: 'Children',
          type: 'node',
        },
      },
    });
  8. How Composify works: The three-step workflow

    main

    Composify follows a specific workflow to enable Server-Driven UI (SDUI) and visual editing:

    1. Register your components: Define editable props, types, and defaults in a Catalog using your actual production components.
    2. Render JSX directly: Use the Renderer to parse JSX strings from your backend/server and render them as React components.
    3. Edit visually: Use the Editor component to allow non-technical users to compose layouts visually using the registered components.
  9. Composify Open Source vs. Composify Cloud

    main

    Composify offers two ways to implement the engine:

    1. Open Source Library: Provides the core engine, including the Editor and the Renderer. You are responsible for the backend plumbing, such as the database, API, version history, and collaboration features.
    2. Composify Cloud: Provides the full infrastructure layer. You register your components in your code, and Composify Cloud handles storage, real-time collaboration, and content delivery, removing the need to maintain your own backend.
  10. Define an Object Property in the Catalog

    main

    An object property type allows you to group multiple controls together into a single structured package in the Composify editor. You define the structure of this object using the fields option. Each entry within fields is itself a property specification, meaning you can nest types like text, number, boolean, or even other object and array types to create complex data structures.

    Catalog.register('Sample', {
      component: Sample,
      props: {
        actions: {
          label: 'Actions',
          type: 'object',
          fields: {
            label: {
              label: 'Label',
              type: 'text',
            },
            primary: {
              label: 'Primary',
              type: 'boolean',
            },
          },
        },
      },
    });
  11. Use Composify as a Headless CMS with your own components

    main

    Unlike traditional CMSs (e.g., WordPress) that lock you into specific themes and plugins, Composify allows you to use your existing production component library as the foundation for your content experience.

    Key benefits include:

    • Component Consistency: Use the same components for marketing pages as you do for your core product.
    • Visual Editing without Templates: Content and marketing teams can build visually using your actual design system rather than being limited by pre-made templates.
    • Zero Gap between CMS and Production: The visual editor operates on your actual production components, ensuring that what is edited is exactly what ships to users.
  12. How Composify works: Server-Driven UI

    main

    Composify enables a Server-Driven UI (SDUI) pattern. Instead of hard-coding UI in your application code, you store JSX strings (the source) on your server.

    1. Engineers build and register reusable React components in a Catalog.
    2. Non-developers use the Editor to compose pages using those components.
    3. The Application fetches the JSX string from the server and uses the Renderer to display it.

    This allows for UI updates, A/B testing, and rapid prototyping without requiring new code deployments or CI/CD cycles.