Setting up JupyterLite#

JupyterLite is a JupyterLab distribution built from all the usual components and extensions that come with JupyterLab, but now running entirely in the browser with no external server needed. In order to use Panel in JupyterLite you will have to build your own distribution. We call this Panelite. You can try out Panelite here.

As a starting point we recommend this guide in the JupyterLite documentation, which will tell you how to set up an environment to begin building JupyterLite.

Create a <lite-dir>#

Once your environment is set up, create a new directory, which will become the source for your JupyterLite distribution. Once created place the file contents you want to make available in JupyterLite into <lite-dir>/files.

Adding extensions#

In order for Panel to set up communication channels inside JupyterLite we have to add the pyviz_comms extension to the environment. Ensure this package is installed in the environment you are building Panel from, e.g. by running pip install pyviz_comms OR by including it in the requirements.txt you used when setting up your build environment.

Optimized wheels (optional)#

To get Panel installed inside a Jupyterlite session we have to install it with piplite. The default Bokeh and Panel packages are quite large since they contain contents which are needed in a server environment. Since we will be running inside Jupyter these contents are not needed. To bundle the optimized packages download them from the CDN and place them in the <lite-dir>/pypi directory. You can download them from the CDN (replacing the latest version numbers):

https://cdn.holoviz.org/panel/1.5.4/dist/wheels/bokeh-3.6.1-py3-none-any.whl
https://cdn.holoviz.org/panel/1.5.4/dist/wheels/panel-1.5.4-py3-none-any.whl

Building Panelite#

Finally cd into your <lite-dir> and run jupyter lite build --output-dir ./dist. This will bundle up the file contents, extensions and wheels into your JupyterLite distribution. You can now easily deploy this to GitHub pages or elsewhere.