# Components and sub-workflows

> Pack a group of nodes into one reusable node, either a sub-workflow you edit in place or a published component with its own inputs, settings and price.

Source: https://nodaro.ai/docs/concepts/components-and-sub-workflows

A **sub-workflow** is a workflow placed inside another workflow as a single node. A **component** is a published, versioned workflow that anyone can drop into their own workflows the same way. Both turn a group of nodes into one node with named inputs and outputs. Use them to reuse a proven chain, such as "remove background, then upscale", and to keep a large workflow readable.

## Sub-workflow or component

| | Sub-workflow | Component |
| --- | --- | --- |
| **Node** | [Sub-Workflow](https://nodaro.ai/docs/nodes/automate/sub-workflow) | [Component](https://nodaro.ai/docs/nodes/automate/component) |
| **What it contains** | One of your own workflows | A workflow someone published as a component, or one you published |
| **Can you see and edit the inside?** | Yes. Open it in place from the node. | No. You set only the inputs and settings its author exposed. |
| **Inputs and outputs** | The ports you declare with [Sub-Workflow Input](https://nodaro.ai/docs/nodes/automate/sub-workflow-input) and [Sub-Workflow Output](https://nodaro.ai/docs/nodes/automate/sub-workflow-output) nodes | The inputs and outputs its author chose when publishing |
| **Changes** | Follows the workflow it points to. Click **Refresh** after you change its ports. | Keeps the version it was added with until you refresh it |
| **Price** | The nodes inside charge their normal price | An estimated price, which can include the author's markup |
| **Best for** | Structuring your own large workflows | Sharing a ready-made step with other people |

## Build a sub-workflow

### Add the Sub-Workflow node

Save your workflow first. Then open the node picker and choose **Automate › Workflows › Sub-Workflow**.

### Create or choose the inner workflow

In the settings panel, click **Create empty sub-workflow**. Nodaro creates a new inner workflow with one input node and one output node, and opens it for editing. To reuse a workflow you already have, choose it in the **Workflow** list instead. Turn on **All Projects** to see workflows from your other projects.

### Declare the inputs and outputs

Inside the inner workflow, the **Sub-Workflow Input** node lists the ports the parent can feed. Each port has a name and a media type: text, image, video, audio or any. The **Sub-Workflow Output** node lists the ports that return results. On the output node, choose which port's result the parent shows as the node's preview, under **Visible Output Port**.

### Wire it in the parent

Go back to the parent with the breadcrumb at the top of the editor. The Sub-Workflow node now has one input and one output for each port. Connect it like any other node, and run the parent workflow.

Workflow: A two-step clean-up chain lives inside one Sub-Workflow node, so the parent canvas stays short.

- Upload Image → Sub-Workflow (image)
- Sub-Workflow → Generate Image (references)
- Generate Image → Generate Video (start frame)

### Open, view and navigate

- **Expand** on the node opens the inner workflow for editing. A breadcrumb at the top of the editor shows the path, such as your workflow › the sub-workflow › a nested one. Click any part of the path to jump there.
- **View Workflow** opens the inner workflow in a read-only window, without leaving the parent.
- If you have unsaved changes when you expand a node, the editor asks you to save or discard them first.

A sub-workflow made with **Create empty sub-workflow** belongs to its parent. It does not appear in your project's list of workflows, and you reach it only from its node. A workflow you choose from the **Workflow** list stays a normal workflow that other parents can use too.

## Routes: several entry points in one workflow

A **route** is a matching pair of one Sub-Workflow Input node and one Sub-Workflow Output node. A workflow can have several routes, and each route is a separate path through it. On the Sub-Workflow node, choose the route under **Route**. The **Interface Preview** shows that route's inputs and outputs.

Only the nodes that the chosen route reaches run. The rest of the inner workflow is left alone.

## Rules and limits

- **Up to 5 levels.** Sub-workflows can contain sub-workflows, up to 5 levels deep. Keep nesting shallow, because deep chains are harder to debug.
- **No loops.** A workflow cannot call itself, directly or through another workflow. The same workflow can still be used twice through two different routes.
- **Every route must be complete.** When you save, Nodaro checks three things. Each input node has a matching output node. Each output node has at least one port. No two input nodes, and no two output nodes, share a route.
- **Refresh after changes.** When you change the ports of a workflow that other workflows use, click **Refresh** on each Sub-Workflow node that uses it.

## Use a component

### Add a Component node

Open the node picker and choose **Automate › Workflows › Component**. Instead of an empty node, the components browser opens, with three tabs: **Browse**, **My Components** and **Favorites**. Search by name, and sort by **Most Popular**, **Newest** or **Most Favorited**.

### Choose a component

Click a component card. The node lands on the canvas already set up, with the component's inputs and outputs.

### Set its inputs and settings

The settings panel has three parts:

- **Inputs**: a connected input shows that it comes from an upstream node. You can type an unconnected text input in place. Image, video and audio inputs need a connection.
- **Settings**: the options the author made adjustable, such as a quality or an aspect ratio.
- **Outputs**: the name and type of each output, to help you wire the next nodes.

### Check the price and run

The settings panel shows an estimated credit price, which updates as you change the settings. Run the node, or the whole workflow, as usual.

A Component node keeps the version it was added with, so a new version from its author never changes your workflow by surprise. Click the refresh icon in the settings panel to move to the latest version and its new price estimate.

## Publish your own component

A component starts as a normal workflow. Publish it from the **Present** tab of the editor:

1. On the Present tab, add the nodes that should become the component's inputs and outputs.
2. Click **Publish** and choose **Component**. Enter a **Component Name** and a description.
3. Under **Component Handles**, name each input and output. Mark the inputs that are required, and choose one output as the **preview** that the node shows on the canvas.
4. Choose whether to list it in the components browser, then publish.

On Nodaro Cloud you can charge a markup when other people use your component: a flat fee in credits, a percentage, or both. The settings show the base cost and what users will pay. Your components appear under **My Components**, where you can edit, list, unlist or archive them.

A workflow can be published both as a component and as a [MiniApp](https://nodaro.ai/docs/concepts/apps). The MiniApp gives people a form to fill in, and the component gives them a node to wire.

## Frequently asked questions

### What is the difference between a sub-workflow and a component?

A sub-workflow is one of your own workflows placed inside another as a node, and you can open and edit it in place. A component is a published, versioned workflow from the components browser, used as a closed node with the inputs, settings and outputs its author chose.

### How deep can sub-workflows be nested?

Up to 5 levels. Nodaro also refuses a loop, such as a workflow that calls itself directly or through another workflow.

### Does a Sub-Workflow or Component node cost credits?

The node itself costs nothing. The nodes inside it charge their normal price when they run. A component shows an estimated price in its settings panel, which can include a markup set by its author.

### Does a component update when its author publishes a new version?

No. A Component node keeps the version it was added with. Click the refresh icon in its settings panel when you want the latest version.
