Create a custom kernel#

Hint

We recommend checking out how to create a server extension first: Create a server extension

Bootstrap the server extension#

Creating a new kernel is very similar to creating a server extension.

Once you have your server extension set up, add the following plugin to register the kernel:

/**
 * A plugin to register the custom kernel.
 */
const kernel: JupyterLiteServerPlugin<void> = {
  id: 'my-custom-kernel:plugin',
  autoStart: true,
  requires: [IKernelSpecs],
  activate: (app: JupyterLiteServer, kernelspecs: IKernelSpecs) => {
    kernelspecs.register({
      spec: {
        name: 'custom',
        display_name: 'Custom Kernel',
        language: 'text',
        argv: [],
        resources: {
          'logo-32x32': '',
          'logo-64x64': '',
        },
      },
      create: async (options: IKernel.IOptions): Promise<IKernel> => {
        return new CustomKernel(options);
      },
    });
  },
};

The Echo Kernel example#

As an alternative, a quick way to bootstrap a new kernel is to start from an existing one.

The jupyterlite-echo-kernel is an example kernel that returns what the user submits as input:

echo-kernel-demo

It is simple and is meant for demo purposes.

If you want to start from that kernel:

  1. For the repo

  2. Follow the dev instructions to build the kernel locally

  3. Once the local setup is ready, you can iterate on the actual logic of the kernel and start implementing the protocol

Examples#

For inspiration you can also check the other JupyterLite kernels: