Routing

typeCAD includes an auto router that generates tracks between connected pins, and a fluent track builder for manual point-to-point routing.

method

route

Auto-route a net or a pin pair. Call it on the PCB instance with a net definition, or directly between pins; the returned tracks are included with create().

Example first

route-net.ts
import { PCB, Resistor } from '@typecad/pcb';

let typecad = new PCB('autoroute_example');

let r1 = new Resistor({ value: '1kohm', reference: 'R1' });
let r2 = new Resistor({ value: '1kohm', reference: 'R2' });

r1.pcb = { x: 10, y: 10, rotation: 0 };
r2.pcb = { x: 20, y: 10, rotation: 0 };

const signal_net = typecad.named('signal').net(r1.pin(1), r2.pin(1));

typecad.route(signal_net);

typecad.create(r1, r2);

route (direct) await pcb.route({ from, to })

Route directly between pins without a named net:

route-direct.ts
let tracks = await typecad.route({
  from: r1.pin(1),
  to: r2.pin(1),
});

typecad.create(r1, r2, ...tracks);

Options

OptionTypeUnitsDescription
from / toPin or array of pinsrequiredThe endpoints
widthnumbermmTrace width — calculated from powerInfo if omitted
layersstring[]layer namesRestrict to specific copper layers (e.g. ['F.Cu', 'B.Cu'])
powerInfoobjectA / °C / µm{ current, maxTempRise, thickness } — automatic IPC-2221 trace width
waypointsarraymmArray of { x, y } points to guide the path
clearancenumbermmMinimum clearance from other objects
gridResolutionnumbermmSearch grid — lower values increase the search space and memory usage
impedanceobjectΩ{ target, tolerance } — widens the trace to hit the target from the stackup
route-config.ts
typecad.route(signal_net, {
    gridResolution: 0.15,
    debug: false,
});
class

TrackBuilder

Fluent API for manual tracks — go point to point, using vias to transition between layers. Nets and connections aren't required: KiCAD connects any track that touches an element with a net.

Example first

manual-track.ts
import { PCB } from '@typecad/pcb';

let pcb = new PCB('typecad_docs');

let power_track = pcb
  .track()
  .powerInfo({ current: 1.0, maxTempRise: 10, thickness: 35 })
  .from({ x: 100, y: 100 }, 'F.Cu', 0.2)
  .to({ x: 110, y: 100 })
  .via({ size: 0.8, drill: 0.4 })
  .to({ x: 110, y: 120, layer: 'B.Cu' });

pcb.create(power_track);

powerInfo .powerInfo({ current, maxTempRise, thickness })

ParameterTypeUnits / valuesDescription
currentnumberampsCurrent the trace carries
maxTempRisenumber°CMaximum wanted temperature rise (default 10)
thicknessnumbermicronsCopper thickness (35 = 1 oz)

Automatic IPC-2221 trace width calculation.

© 2026 typeCAD — code-defined electronics github