# Introducing Bun for Analysis

> Write TypeScript or JavaScript in TagoIO with Bun, import packages by name, and reuse successfully built bundles across Analysis runs.

![Introducing Bun for Analysis](https://tago.io/og/blog/introducing-bun-analysis-runtime.png)

Bun is now available for TagoIO Analysis. It runs TypeScript and JavaScript directly, with package imports written the way you would write them in a Node.js project. TagoIO handles the build for hosted execution, so you can maintain your script without a separate local compilation or bundling step.

Use Bun when processing device data also means calling another service or using a library. Turn a high-temperature reading into a maintenance request, format readings for a reporting system, or combine sensor data with information from an external API. Your Analysis can handle the processing and the integration without a separate server to maintain.

## Write TypeScript with familiar imports

Import the TagoIO JavaScript SDK as `@tago-io/sdk`, or a date library as `dayjs`. Bun resolves packages by name. TypeScript support is built in, so you can keep types in the script you edit on TagoIO instead of compiling it to JavaScript before uploading.

Bun does not accept Deno's `npm:` or `jsr:` import prefixes. Use plain package names, and include a version in an import when you need a specific package release.

## Save a bundle, reuse it across runs

![TypeScript or JavaScript source imports @tago-io/sdk and dayjs; a successful build combines the saved script and packages into one bundle, which two runs reuse without installing packages](https://tago.io/images/blog/introducing-bun-analysis-runtime/bundle-flow.svg)

When you save a version, TagoIO builds the script and its packages into one file. After a successful build, subsequent runs use that saved bundle without installing packages again. Dependency preparation happens when you save, rather than being repeated for each execution.

That benefit depends on a successful build. Some failures, such as a bundle larger than 10 MB, fall back to installing packages on every run. Syntax errors or missing packages stop execution instead. The [Bun runtime guide](https://docs.tago.io/docs/tagoio/analysis/runtimes#bun-bun-rt2026) explains build failures and how to resolve them.

## Connect readings to an external service

![A Bun Analysis checks a 38 °C reading from greenhouse-01 against a 35 °C limit, formats 14:05 as 2:05 PM with dayjs, and sends an Inspect cooling work order to a maintenance API, which returns 201 Created](https://tago.io/images/blog/introducing-bun-analysis-runtime/integration.svg)

For example, a greenhouse sensor reports 38 °C. Your Bun Analysis can read the device data, combine it with the site's details, and format the timestamp with a package. It then calls your maintenance system's API to create a work order: "Inspect cooling."

You supply the service's credentials and request format. The same approach works for sending formatted readings to a reporting API or enriching a device record with data fetched from another system.

## How Bun compares with other runtimes

- **Node.js:** Build and test a bundled script locally, then upload it. Bun moves compilation and dependency bundling into TagoIO, so you can edit TypeScript directly in Admin.
- **Deno:** Both runtimes let you maintain TypeScript in the editor. Bun uses plain package-name imports; Deno uses `npm:` specifiers or URLs.
- **Python:** Keep it for data work that depends on libraries such as `pandas`, `numpy`, or `scipy`. Choose Bun when the job fits JavaScript or TypeScript and their packages.

Hosted Bun execution counts toward your Profile's monthly [Analysis Service](https://docs.tago.io/docs/tagoio/profiles/services/analysis-service) limit.

## Compare runtime speed on the same workload

A sensor-data processing comparison across runtimes:

Median execution time

| Runtime | 1,000 readings | 100,000 readings |
| --- | --- | --- |
| Luau 0.728 | 0.74 ms | 30.60 ms |
| Bun 1.4.2 | 19.21 ms | 27.49 ms |
| Deno 2.4.4 | 30.63 ms | 37.87 ms |
| Node.js 24.21.0 | 29.74 ms | 37.98 ms |
| Python 3.13 | 69.70 ms | 138.52 ms |

Each runtime uses the version TagoIO hosts. Luau runs inside TagoIO without starting a separate process, so its times cover only the script. The other runtimes start a new process on every run, and that startup accounts for most of their time at 1,000 readings.

### How speed affects usage

For Bun, Deno, Node.js, and Python, faster hosted execution can reduce [Analysis Service](https://docs.tago.io/docs/tagoio/profiles/services/analysis-service) usage when it falls into a lower billed increment. Each run has a one-second minimum, so sub-second differences alone do not show billing savings.

## Build and test in Admin

Create a new Analysis, choose **Bun** (`bun-rt2026`) in **Runtime**, and select **TagoIO** under **Runs on**. Write your script in the editor and save a version. Check the Console for build errors, then click **Run** to execute it and inspect its logs.

TagoAI can help write and debug your script.

## Get started

Read the [Analysis Runtimes guide](https://docs.tago.io/docs/tagoio/analysis/runtimes), then [create a new Analysis](https://docs.tago.io/docs/tagoio/analysis/creating-analysis) in [Admin](https://admin.tago.io). See the [October 13 release notes](https://changelog.tago.io/server/v10-6-0/) for the Bun announcement.

[llms.txt](https://tago.io/llms.txt)
