An intermediate-level TypeScript framework for building web applications with Rhino Compute and Grasshopper.
selva-compute simplifies the process of communicating with Rhino Compute, handling Grasshopper definitions, and visualizing results in the browser with Three.js.
npm install selva-compute three
(Note: three is a peer dependency if you use the visualization features)
selva-compute provides a type-safe, production-ready foundation for building with Rhino Compute:
GrasshopperClient and GrasshopperResponseProcessor to get started quicklyinitScene() and configurable rendering optionsWhether you're building a simple solver or a complex web application, selva-compute handles the complexity so you can focus on your Grasshopper definitions.
Note: The library currently focuses on the Grasshopper endpoint but is designed to support other Rhino Compute endpoints in future releases.
// Configuration
const DEFINITION_FILE = 'my-definition.gh';
const COMPUTE_SERVER = 'http://localhost:6500';
const API_KEY = 'your-api-key';
const config = {
serverUrl: COMPUTE_SERVER,
apiKey: API_KEY
} as GrasshopperComputeConfig;
let client: GrasshopperClient | null = null;
// Step 1: Create and initialize the client
client = await GrasshopperClient.create(config);
// Step 2: Get definition inputs and outputs
const io = await client.getIO(DEFINITION_FILE);
// Step 3: Build input data tree from definition parameters
const inputTree = TreeBuilder.fromInputParams(io.inputs);
// Step 4: Run the computation
const result = await client.solve(DEFINITION_FILE, inputTree);
// Step 5: Process and display results
const processor = new GrasshopperResponseProcessor(result);
const { values } = processor.getValues();
selva-compute works with both standard Rhino Compute and enhanced versions:
Standard Rhino Compute – The official McNeel repository works for basic Grasshopper solving with core features.
Enhanced Setup (Recommended) – Unlock advanced features:
groupName propertyFeatures requiring the enhanced setup will be clearly marked in the documentation.
This library is built on production experience and draws from several official McNeel repositories. Where code has been adapted, it is clearly marked in the relevant files.
Key References:
MIT