Skip to content

Add Live Code with JupyterLite kernel #70

Description

@guenp

I'd like to enable executable code cells in the static HTML assets, see: https://jupyterbook.org/en/stable/interactive/thebe.html, except using JupyterLite kernel instead of MyBinder.

Activity

  1. guenp commented on Jun 28, 2025

    @guenp
    ContributorAuthor

    Opened a PR here to set up Thebe: #69

  2. guenp commented on Jun 28, 2025

    @guenp
    ContributorAuthor

    Looks like sphinx-thebe does not support using a JupyterLite kernel instead of MyBinder: executablebooks/sphinx-thebe#27

  3. rossbar commented on Jun 28, 2025

    @rossbar
    Member

    I'm very interested in this feature as well - I think it'd be a huge improvement to UX to have the execution live within the served page as opposed to the swap over to a different (e.g. jupyter lab) interface.

  4. guenp commented on Jun 28, 2025

    @guenp
    ContributorAuthor

    Agreed this would be a nice UX!

    In the end what I think needs to happen to enable this is to render the HTML using thebe-lite (see https://jupyter-book.github.io/thebe/ and https://github.com/jupyter-book/thebe/tree/main/packages/lite). There are a few ways we can do this -- probably the easiest route is a contribution to sphinx-thebe, we'd need to update thebe_config to enable this Thebe configuration:

    <script type="text/x-thebe-config">
    {
        useBinder: false,
        useJupyterLite: true
    }
    </script>
    

    as well as include all static thebe-lite assets (including the pyolite wheels).

    Here's a screenshot of a quick demo based on just editing the static HTML generated by Sphinx:

    Image

    Instead of clicking the "activate" button you'd hover over the spaceship and click "Live Code", which is then configured to activate JupyterLite instead of a Binder kernel.

    Edit: Another thing that would be nice to add to the Launch (spaceship) button is an "open in JupyterLite" option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions