Skip to main content

🪐 JupyterLabApp Component

The JupyterLabApp component embeds a complete JupyterLab application inside your React application. This gives you access to the full JupyterLab interface including the file browser, notebook editor, terminal, and all JupyterLab extensions.

Overview​

Unlike other Jupyter UI components that provide individual pieces of functionality, JupyterLabApp renders the entire JupyterLab application. This is useful when you need:

  • Full JupyterLab UI within your application
  • Access to JupyterLab's plugin system
  • All JupyterLab features without building custom UI

Installation​

npm install @datalayer/jupyter-react
# or
yarn add @datalayer/jupyter-react

Basic Usage​

import { JupyterLabApp, JupyterReactTheme } from '@datalayer/jupyter-react';

function App() {
return (
<JupyterReactTheme>
<JupyterLabApp hostId="jupyterlab-app" height="100vh" />
</JupyterReactTheme>
);
}

Props​

PropTypeDefaultDescription
hostIdstring'app-example-id'DOM element ID for the JupyterLab container
heightstring | number'100vh'Height of the JupyterLab container
widthstring | number'100%'Width of the JupyterLab container
positionstring'relative'CSS position property
theme'light' | 'dark''light'Color theme for JupyterLab
headlessbooleanfalseRun JupyterLab without UI (for programmatic access)
nosplashbooleanfalseDisable the splash screen
devModebooleanfalseEnable development mode
serverlessbooleanfalseRun without a Jupyter server
startDefaultKernelbooleanfalseStart a default kernel on load
serviceManagerServiceManager-Custom JupyterLab service manager
pluginsJupyterLab.IPluginModule[][]Additional JupyterLab plugins to load
pluginPromisesPromise<IPluginModule>[]Core pluginsAsync plugin modules to load
disabledPluginsstring[][]Plugin IDs to disable
mimeRenderersIRenderMime.IExtensionModule[][]Custom MIME renderers
mimeRendererPromisesPromise<IExtensionModule>[]Core renderersAsync MIME renderer modules
onJupyterLab(adapter) => void-Callback when JupyterLab is ready
onPlugin(plugin) => void-Callback when a specific plugin is loaded
pluginIdstring-Plugin ID to pass to onPlugin
PluginTypeany-Type of plugin for onPlugin

Examples​

With Custom Dimensions​

<JupyterLabApp
hostId="my-jupyterlab"
height="600px"
width="100%"
position="relative"
/>

Dark Theme​

<JupyterLabApp hostId="jupyterlab-dark" theme="dark" height="100vh" />

Accessing JupyterLab Adapter​

The onJupyterLab callback gives you access to the JupyterLabAppAdapter which provides programmatic control:

import { JupyterLabApp, JupyterLabAppAdapter } from '@datalayer/jupyter-react';

function App() {
const handleJupyterLab = (adapter: JupyterLabAppAdapter) => {
// Access JupyterLab services
const commands = adapter.commands;
const shell = adapter.shell;

// Execute commands
commands.execute('filebrowser:toggle-main');

// Access registered services
const themeManager = adapter.service(
'@jupyterlab/apputils-extension:themes',
);
};

return (
<JupyterLabApp hostId="jupyterlab-app" onJupyterLab={handleJupyterLab} />
);
}

Headless Mode​

Run JupyterLab without the UI for programmatic operations:

<JupyterLabApp
hostId="jupyterlab-headless"
headless={true}
onJupyterLab={adapter => {
// Use adapter for programmatic operations
// UI is hidden but services are available
}}
/>

Disabling Plugins​

<JupyterLabApp
hostId="jupyterlab-custom"
disabledPlugins={[
'@jupyterlab/terminal-extension:plugin',
'@jupyterlab/git:plugin',
]}
/>

Custom Plugins​

import myPlugin from './myPlugin';

<JupyterLabApp
hostId="jupyterlab-extended"
plugins={[myPlugin]}
pluginPromises={[import('@jupyterlab/git')]}
/>;

JupyterLabAppAdapter​

The adapter provides access to JupyterLab internals:

Property/MethodTypeDescription
jupyterLabJupyterLabThe JupyterLab application instance
shellLabShellThe JupyterLab shell (main UI container)
commandsCommandRegistryCommand registry for executing actions
docRegistryDocumentRegistryDocument type registry
readyPromise<void>Promise that resolves when JupyterLab is ready
service(pluginId)(id: string) => anyGet a registered service by plugin ID
getNotebookTracker()INotebookTrackerGet the notebook tracker
getNotebookPanel(id)NotebookPanelGet a notebook panel by ID

Styling​

The component automatically includes JupyterLab CSS. You can customize styles:

/* Target the JupyterLab shell */
#jupyterlab-app .jp-LabShell {
/* Custom styles */
}

/* Target specific panels */
#jupyterlab-app .jp-SideBar {
width: 250px;
}

Notes​

  • The component creates a single JupyterLab instance per hostId
  • Multiple JupyterLabApp components require unique hostId values
  • Use headless={true} when you only need programmatic access to JupyterLab services
  • The component is memoized to prevent unnecessary re-renders