# Communication between a host page and a JupyterLite instance running in an IFrame When a JupyterLite instance is embedded in a website via an IFrame, it may be relevant to establish a communication channel between the host page and the instance. ## Using the `jupyter-iframe-commands` extension The [jupyter-iframe-commands](https://github.com/TileDB-Inc/jupyter-iframe-commands) extension is a JupyterLab extension that provides an API to execute JupyterLab commands from a host page, with JupyterLite embedded in an iframe. ### Installation Install the extension in your environment: ```bash pip install jupyter-iframe-commands ``` Then rebuild your JupyterLite site: ```bash jupyter lite build ``` ### Usage The extension consists of two packages: 1. `jupyter-iframe-commands`: The JupyterLab extension that runs inside the iframe 2. `jupyter-iframe-commands-host`: A JavaScript package for the host page interacting with the JupyterLite instance To use the extension in your host page: ```html JupyterLite in an iframe

JupyterLite with command bridge

``` The `jupyter-iframe-commands` extension provides access to all JupyterLab commands, so you can control various aspects of the JupyterLite instance, such as: - Toggling UI elements (sidebars, panels, etc.) - Creating new notebooks or files - Changing the theme For more information, refer to the [jupyter-iframe-commands repository](https://github.com/TileDB-Inc/jupyter-iframe-commands). ## Exposing additional functionality If you need additional functionality beyond what the `jupyter-iframe-commands` extension provides, you can develop your own custom JupyterLab extension. Custom extensions can implement new commands to expose more functionality to the host page. For information on developing JupyterLab extensions, refer to the [JupyterLab Extension Developer Guide](https://jupyterlab.readthedocs.io/en/stable/extension/extension_dev.html).