Previews on JupyterHub
On a JupyterHub, curvenote start runs on the hub’s server, not on your computer, so the http://localhost:3000 link it prints doesn’t reach your browser. jupyter
There are two ways to open a preview: start it yourself from a JupyterLab terminal, or click a Curvenote preview launcher that your hub’s admin has added.

Figure 1:A Curvenote preview in a JupyterLab tab on a JupyterHub, opened from the Curvenote preview launcher.
What the hub needs¶
Your hub’s admin adds three things to the environment each user’s server runs in, usually the single-user image:
Node.js 20.19, 22.12 or 24
the Curvenote CLI,
npm install -g curvenote(see Installing)jupyter-server-proxy, from pip or conda-forge
The server also needs to reach github.com and registry.npmjs.org the first time a project starts, to download the Curvenote theme and its dependencies. For an image built on the Jupyter Docker Stacks, such as those used with Zero to JupyterHub, that is:
FROM quay.io/jupyter/base-notebook:latest
RUN mamba install --yes 'nodejs=24' && \
pip install --no-cache-dir jupyter-server-proxy && \
npm install --global curvenote && \
mamba clean --all --force-pkgs-dirs --yes && \
npm cache clean --forceUsers need their server restarted once jupyter-server-proxy is installed.
Start a preview from a terminal¶
In a JupyterLab terminal, go to your project’s folder and run:
export BASE_PATH="${JUPYTERHUB_SERVICE_PREFIX}proxy/absolute/3000"
curvenote start --port 3000JUPYTERHUB_SERVICE_PREFIX is the path of your JupyterLab, such as /user/ada/, so BASE_PATH becomes /user/ada/proxy/absolute/3000. That’s where jupyter-server-proxy serves port 3000, and the theme uses it for all its links, scripts and data.
Then open your hub’s address followed by that path and the ?params= part of the link the CLI printed:
https://hub.example.org/user/ada/proxy/absolute/3000/?params=eyJ2ZXJzaW9uIjoiMC4xOC4wIn0The link the CLI prints has the wrong address for a hub, and shows the port twice, for example http://localhost:30003000?params=…. Copy only its ?params=… part. You can open the preview in a new browser tab, and it reloads by itself when you save a page, as it does on your own computer.
Getting the address right¶
| Address | BASE_PATH | Result |
|---|---|---|
…/proxy/absolute/3000/ | the same path, as above | The preview works |
…/proxy/3000/ | set or not | Not found, or a blank page |
…/proxy/absolute/3000/ | not set | A blank page: the theme’s scripts and styles don’t load |
Use
proxy/absolute/. At/proxy/3000/, jupyter-server-proxy removes the path before the request reaches the theme, and the theme can’t work out where it is.The two ports must match. If port 3000 is busy,
curvenote startpicks another and prints it. Stop it withCtrl+C, then start again with a free port in both--portandBASE_PATH. Use a different port for each project you preview at the same time.Each run has its own
?params=. A browser that opens the preview without this run’s link, such as a tab left from an earlier run, gets a page asking you to open the link fromcurvenote start. Other tabs in the browser you opened it in work without it.
The theme keeps only letters, digits, -, _ and / in BASE_PATH. If your JupyterHub username has any other character, such as ada.lovelace or an email address, the path it uses doesn’t match your JupyterLab’s and the preview isn’t found. There’s no workaround yet, from a terminal or the launcher.
The preview stops when you stop curvenote start or your JupyterLab server stops.
Add a Curvenote preview launcher¶
An admin can add a Curvenote preview card to the JupyterLab launcher. jupyter-server-proxy runs curvenote start for a project folder the first time someone opens it, on a port it chooses, and stops it with their server, so users don’t need a terminal or a port.

Figure 2:The Curvenote preview launcher card, added with jupyter-server-proxy’s ServerProxy.servers setting.
Add this to the server’s config, for example in /usr/local/etc/jupyter/jupyter_server_config.py in the single-user image:
import base64, json, os, subprocess
c = get_config()
# The link `curvenote start` prints carries the CLI's version in ?params=; the launcher does too
version = subprocess.run(["curvenote", "--version"], capture_output=True, text=True).stdout
packet = json.dumps({"version": version.strip().lstrip("v")}, separators=(",", ":"))
params = base64.urlsafe_b64encode(packet.encode()).decode().rstrip("=")
c.ServerProxy.servers = {
"curvenote": {
"command": ["sh", "-c", 'cd "$CURVENOTE_PROJECT" && exec curvenote start --port "$0"', "{port}"],
"environment": {
"BASE_PATH": "{base_url}curvenote",
"CURVENOTE_PROJECT": os.environ.get("CURVENOTE_PROJECT", os.path.expanduser("~/work")),
},
"absolute_url": True,
"timeout": 180,
"new_browser_tab": False,
"launcher_entry": {
"title": "Curvenote preview",
"path_info": f"curvenote/?params={params}",
"icon_path": "/usr/local/share/curvenote/curvenote.svg",
},
},
}absolute_urlandBASE_PATHdo whatproxy/absolute/andBASE_PATHdo in a terminal, at/user/<name>/curvenote/.The project is the folder in the
CURVENOTE_PROJECTenvironment variable,~/workby default. The launcher previews one folder per user, so it suits hubs where each user works on one project, such as a course or a submission template.new_browser_tab: Falseopens the preview in a JupyterLab tab, as in Figure 1;Trueopens a browser tab.timeoutgives the first start time to download the theme and build the project.icon_pathis an SVG for the card. JupyterLab shows it only in the launcher’s Notebook section, where the card goes by default.
To preview other folders, users start them from a terminal as above.
- CLI
- Command Line Interface