---
title: "Publish"
description: "Publishing a plugin with the designer-plugin library"
url: https://developer.disguise.one/plugins/designer-plugin/publish/
---

# Publish

The `DesignerPlugin` class publishes your plugin via DNS-SD (Bonjour/mDNS), making it discoverable by Disguise Designer on the local network. Once published, Designer can find and connect to the plugin automatically.

The `port` parameter corresponds to the HTTP server that hosts your plugin’s web user interface.

## Configuration File

Place a `d3plugin.json` file in your plugin’s working directory (usually alongside the plugin script). Designer reads this file to identify the plugin.

```json
{
    "name": "MyPlugin",
    "requiresSession": true
}
```

See the [developer documentation](https://developer.disguise.one/plugins/) for the full list of supported fields.

* * *

## Usage

Use `DesignerPlugin.default_init(port)` to load plugin metadata from `d3plugin.json` and publish on the given port. Both synchronous and asynchronous usage are supported:

**Synchronous**

```python
from designer_plugin import DesignerPlugin
from time import sleep

with DesignerPlugin.default_init(12345) as plugin:
    print("Plugin is published. Press Ctrl+C to stop.")
    try:
        while True:
            sleep(3600)
    except KeyboardInterrupt:
        pass
```

**Asynchronous**

```python
from designer_plugin import DesignerPlugin
import asyncio

async def main():
    async with DesignerPlugin.default_init(port=12345) as plugin:
        print("Plugin is published. Press Ctrl+C to stop.")
        try:
            await asyncio.Event().wait()
        except asyncio.CancelledError:
            pass

asyncio.run(main())
```

* * *

## Publish Options

If you prefer not to use `d3plugin.json`, construct `DesignerPlugin` directly. The plugin `name` and `port` are required. You can also supply `hostname` to direct Designer to a specific machine when opening the plugin’s web UI, along with other metadata:

```python
from designer_plugin import DesignerPlugin

plugin = DesignerPlugin(
    name="MyPlugin",
    port=12345,
    hostname="my-machine.local",   # optional — defaults to machine hostname
    requires_session=True,         # optional
)

with plugin:
    input("Press Enter to stop...")
```

To load configuration from a JSON file at a custom path, use `from_json_file`:

```python
with DesignerPlugin.from_json_file("config/my_plugin.json", port=12345) as plugin:
    input("Press Enter to stop...")
```

* * *

## Next Steps

Once your plugin is published and discoverable, connect to Designer and execute Python code remotely:

-   [Client API](/plugins/designer-plugin/client-api) — class-based approach using `D3PluginClient`
-   [Functional API](/plugins/designer-plugin/functional-api) — decorator-based approach using `@d3function` and `@d3pythonscript`
