Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including zwitterion with all npm packages installed. Try it out:

zwitterion lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("zwitterion/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

zwitterion v0.31.0

Auto-transpiling, live-reloading, and SPA-ing server for JavaScript, TypeScript, JSX, TSX, and WebAssembly.

CircleCI npm version dependency Status devDependency Status


NOTICE - v0.30.0 and up use an experimental import maps feature, and will not work for most browsers. Install a prior version for general browser compatibility

Zwitterion is a server for web applications that provides automatic transpilation, live-reload, and SPA (single-page application) support out of the box. It allows you to develop web platform applications using the latest versions of JavaScript, TypeScript, JSX, TSX, or WebAssembly without a complicated build step.

Just include files directly in <script> tags:

<script src="hello-world.ts"></script>

or as ES module imports:

import {hello} from './hello-world';

All features that the TypeScript compiler provides are automatically available, including ES modules, async/await, and Object spread. Zwitterion even provides support for bare specifiers:

import {createStore} from 'redux';

Zwitterion lets you get back to the good old days of web development. Just write your source code and run it in the browser.

Current Features

  • Automatic JavaScript transpilation (JS -> JS)
  • Automatic TypeScript transpilation (TS -> JS)
  • Automatic JSX transpilation (JSX -> JS)
  • Automatic TSX transpilation (TSX -> JS)
  • Automatic WASM transpilation (WASM -> JS Module)
  • Automatic WAST transpilation (WAST -> JS Module)
  • Bare specifiers (import * as stuff from 'library'; instead of import * as stuff from '../node_modules/library/index.js';)

Installation and Basic Use

Local Installation and Use

Install Zwitterion in the directory that you would like to serve files from:

npm install zwitterion

Run Zwitterion by accessing its binary directly from the terminal:


or from an npm script:

  "scripts": {
    "start": "zwitterion"

Global Installation and Use

Install Zwitterion globally to use across projects:

npm install -g zwitterion

Run Zwitterion from the terminal:


or from an npm script:

  "scripts": {
    "start": "zwitterion"

Production Use

To create a static build suitable for uploading to a CDN (content delivery network), run Zwitterion with the --build-static option. The static files will be created in a directory called dist in the directory Zwitterion is started from. You may need to add the application/javascript MIME type to your hosting provider for your TypeScript files.

From the terminal:

zwitterion --build-static

From an npm script:

  "scripts": {
    "build-static": "zwitterion --build-static"

Special Considerations

Root File

It's important to note that Zwitterion assumes that the root file (the file found at /) of your web application is always an index.html file. That index.html file must have a <head> element for file watching to work (this will not be required in the future).

ES Modules

Zwitterion depends on native browser support for ES modules (import/export syntax). You must add the type="module" attribute to script tags that reference modules, for example:

<script type="module" src="amazing-module.ts"></script>

Or from a non-html file (if you leave out the file extension it will be assumed to be a TypeScript file):

import {amazingFunction} from './amazing-module';

WASM and WAST Files

Include .wast or .wasm files in your source code and imports just like any other file type. The exports of your WASM module will be available as the default export of the transpiled JS module:

;; /add.wast
    (func $add (param i32 i32) (result i32)
            (get_local 0)
            (get_local 1)))
    (export "add" (func $add)))
import AddWASM from './add.wast';

console.log(AddWASM.add(2, 2));
// 4


It's important to note that Zwitterion does not bundle files nor engage in tree shaking. This may impact the performance of your application. HTTP2 and ES modules may help with performance, but at this point in time signs tend to point toward worse performance. Zwitterion has plans to improve performance by automatically generating HTTP2 server push information from the static build, and looking into tree shaking, but it is unclear what affect this will have. Stay tuned for more information about performance as Zwitterion matures.

With all of the above being said, the performance implications are unclear. Measure for yourself.

Read the following for more information on bundling versus not bundling with HTTP2:


The Future

Here's a rough roadmap of the big future plans:

  • [ ] Investigate performance, make sure Zwitterion can beat out the complicated bundlers (tree shaking and bundling)
  • [ ] Add support for Rust, C, C++ and any other popular language that can compile to WebAssembly

Command-line Options


Specify the server's port:

-p [port]


--port [port]

Watch Files

Watch files in current directory and reload browser on changes:




Build Static

Create a static build of the current working directory. The output will be in a directory called dist in the current working directory:


Exclude Dirs

A space-separated list of directories to exclude from the static build:

--exclude-dirs [excludeDirs...]


The ECMAScript version to compile to; if omitted, defaults to ES2015. Any targets supported by the TypeScript compiler are supported here (ES3, ES5, ES6/ES2015, ES2016, ES2017, ESNext):

--target [target]

Disable SPA

Disable the SPA redirect to index.html:


Under the Hood

Zwitterion is simple. It is more or less a static file server, but it rewrites requested files in memory as necessary to return to the client. For example, if a TypeScript file is requested from the client, Zwitterion will retrieve the text of the file, compile it to JavaScript, compile it from CommonJS to ES Modules, and then return the compiled text to the client. The same thing is done for JavaScript files. In fact, nearly the same process will be used for any file extension that we want to support in the future. For example, in the future, if a C file is requested it will be read into memory, the text will be compiled to WebAssembly, and the WebAssembly will be returned to the client. All of this compilation is done server-side and hidden from the user. To the user, it's just a static file server.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free