Adding Projects
June 27, 2026 ยท View on GitHub
- Back to README
- User Manual
- Installation
- Adding Projects
- Development
- Server Maintenance
- Troubleshoot
Adding Projects
It is possible to add additional projects to the web editor which can be selected from the dropdown or through the URL.
The default directory for projects is ./Projects/ but this can be changed by setting
the environment variable PROJECTS_BASE_PATH. This needs to be set for the build process (npm run build:server) and for the production mode (npm run prod / ecosystem.config.cjs) and it contains a
relativ path from the project's root directory.
Inside this folder, new Lean projects can be created containing 2 special files:
leanweb-config.json(mandatory)leanweb-build.sh(optional)
The name of the folder is simultaneously the key used in the URL, e.g. a project in the folder MyCoolProject can be accessed via lean.your.website.com/#project=MyCoolProject.
You might want to look at the provided MathlibDemo project for comparison.
project structure
Any lake project can be used as a project. However, same features make some assumptions:
- In order for
laketo use anyleanOptionsspecified in the project's lakefile, you must make sure there is a fileProjects/MyCoolProject/MyCoolProject.leanwhere folder name and file name coincide. - The download button creates a ZIP where the editor content is placed in
MyCoolProject/MyCoolProject.leanand the fileslean_toolchain,lake-manifest.json,lakefile.lean(orlakefile.toml) are copied over. In particular, if the lakefile defines other targets, the downloaded lake project might not work as there might be missing these files.
project config
The file leanweb-config.json takes the following form:
{
"name": "Display name",
"default": false,
"hidden": false,
"sortOrder": 0,
"examples": [
{ "file": "MathlibDemo/Bijection.lean", "name": "Example's display name" },
...
]
}
name: The display name of the project as shown in the dropdown menu. The substrings_Vers_and_LeanVers_in the project name will be replaced by indicators of which version is being used:- If the toolchain is in a recognized format (a regular release like
v4.30.0-rc1or nightly release like2026-04-04), then_Vers_will be replaced by the version number (e.g.v4.30.0-rc1) and_LeanVers_will be replaced by "Lean" followed by the version number (e.g.Lean v4.30.0-rc1) - If the toolchain is not in a recognized format, both
_Vers_and_LeanVers_will be replaced by "Lean".
- If the toolchain is in a recognized format (a regular release like
default: There must be exactly one project with this set totrue. This is the project loaded by default and when no project is specified in the url.hidden: If set totrue, then the project does not appear in the dropdown and can only be accessed via direct link.sortOrder(non-negative number): sort order of the projects in the dropdown. The default always comes first, then projects with highersortOrdervalue. Ties are resolved alphabetically.examples: list of examples. The path is relativ to the project's directory, e.g.{PROJECTS_BASE_PATH}/{PROJECT_FOLDER}/{EXAMPLE_PATH.lean}
automatic builds
If the project contains a file leanweb-build.sh, it will be executed as part of npm run build:server.
This can be used to automatically update and build the project. A typical build script could look like
this:
#!/usr/bin/env bash
# Operate in the directory where this file is located
cd $(dirname \$0)
# add code here to update the project correctly
lake build
If no build script exists, you must build your Lean projects manually.