# Get started

> Install TypeFlow and create your first typewriter animation in vanilla JS or modern frameworks.

Canonical documentation: https://staticcanvas.github.io/typeflow/getting-started/


## Installation

Install `@staticcanvas/typeflow` version `0.35.0` from npm, jsr, or load it directly from modern CDNs.

```bash
npm install @staticcanvas/typeflow@0.35.0
# pnpm add @staticcanvas/typeflow@0.35.0
# npx jsr add @staticcanvas/typeflow@0.35.0
```

## Basic Usage

Import the singleton `TypeFlow` instance and call `type()` on any DOM element or query selector string:

```javascript
import { TypeFlow } from &#39;@staticcanvas/typeflow&#39;;

// Animate a simple heading
const controller = TypeFlow.type(&#39;#headline&#39;, &#39;Building refined web experiences.&#39;, {
  speed: 45,
  cursor: &#39;|&#39;,
  cursorBlink: true,
  onComplete: (text) =&gt; console.log(&#39;Animation completed:&#39;, text)
});
```

## Erasing Content

TypeFlow provides fine-grained erase control with multiple erase styles:

```javascript
import { TypeFlow } from &#39;@staticcanvas/typeflow&#39;;

// Erase from the right (backspace style)
TypeFlow.erase(&#39;#headline&#39;, {
  speed: 20,
  eraseStyle: &#39;end&#39;
});

// Left-erosion erase style (start)
TypeFlow.erase(&#39;#headline&#39;, {
  speed: 15,
  eraseStyle: &#39;start&#39;
});
```

## Stopping Animations

All `type()`, `erase()`, `sequence()`, and `rotate()` methods return a `TypeFlowController` object:

```javascript
const controller = TypeFlow.type(&#39;#status&#39;, &#39;Fetching system metrics...&#39;);

// Abort typing at any time
button.addEventListener(&#39;click&#39;, () =&gt; {
  controller.stop();
});

// The controller promise always resolves safely without rejecting
controller.promise.then(({ completed, text }) =&gt; {
  if (!completed) {
    console.log(&#39;Interrupted early. Rendered text:&#39;, text);
  }
});
```

## What&#39;s Next?

- Explore [Sequences &amp; Rotators](https://staticcanvas.github.io/typeflow/guides/sequences/) to build multi-step conversational UI flows.
- Review [HTML &amp; Sanitization](https://staticcanvas.github.io/typeflow/guides/html-sanitization/) for rich formatted typography.
- Test options dynamically in the [Interactive Playground](https://staticcanvas.github.io/typeflow/playground/).

