Create a JupyterLite archive that can be used offline#
It is possible to create a fully self-contained JupyterLite archive with no request to external services.
Some configuration parts depend on the kernels you might be using.
This guide focuses on two Python kernels only: Xeus Python and Pyodide.
With the Xeus Python kernel#
Using the Xeus Python kernel, packages are automatically pre-installed at build time.
They are then available as static assets in the JupyterLite output directory.
These assets are available offline by default, there is no extra configuration necessary.
See the related guide for more information.
With the Pyodide kernel#
Configure the Pyodide kernel#
By default the Pyodide files are fetched from a CDN.
The full Pyodide distribution can be pretty heavy (~180MB), but it’s possible to self-host it.
--pyodide flag to specify the Pyodide distribution you would like to use. For
jupyter lite build --pyodide https://github.com/pyodide/pyodide/releases/download/0.22.1/pyodide-0.22.1.tar.bz2
Generally, a version of
pyodide_kernel is likely only compatible with variants of the
x.y.z version against which the release was tested, as both python
and JS APIs are still changing frequently on both sides of the dependency.
Configure the piplite wheels#
By default calling
%pip install or
piplite.install() downloads and installs packages
from the public PyPI.
Instead you can configure a list of packages that will be downloaded at build time so they can be hosted alongside your JupyterLite website.
See Ship additional Pyodide wheels at build time for more information.
Concretely that means populating a list of URLs for downloading wheels. A good example for this is the configuration used for the JupyterLite demo website: jupyter_lite_config.json
The relevant part of
jupyter_lite_config.json is the
piplite_urls list which looks
like the following:
Tweak this list based on the packages you would like to serve statically.
Offline Progressive Web App (PWA)#
JupyterLite can be used as a Progressive Web App (PWA) on mobile devices, but also on desktop.
When JupyterLite is configured to work offline as detailed in this guide, it should be possible to use JupyterLite as a PWA without any network connection. There might still be a need for using the app while still connected to the Internet first, so the underlying Service Worker can cache the assets.
Check out the Using guide for more details on how to install JupyterLite as an application.
Check out the CLI Reference for more details.