> ## Documentation Index
> Fetch the complete documentation index at: https://forst-lang.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

**Forst is a programming language that helps you move TypeScript backends to Golang.**

To accomplish this, it supports you in four key ways:

| Benefit | How it works |
| - | - |
| Go ecosystem | **Compiles directly to Go.** You get full access to the Go package ecosystem, standard library and build tools. |
| TypeScript integration | **Generates native TS definitions and a client** directly from your backend source. No need for intermediate languages like GraphQL or Protobuf just for type safety. |
| Node.js interop | **Call existing Node.js code** directly from Forst to keep your existing tools and libraries during migration. |
| Incremental migration | Allows you to **move small parts of your code at a time** while your existing codebase keeps running, so you can keep shipping during migration. |

## Why?

Building backend APIs often forces a trade off between runtime performance and developer speed. Maintaining separate schema contracts leads to lots of glue code. Full backend rewrites into more performant languages are often impossible to do safely.

Forst exists to remove that friction. You can migrate incrementally or write completely new backends with native performance and an ergonomic DX by design.

## Validation and errors

**Constraints** validate incoming data automatically before it reaches your
application logic. Constraints on the type replace manual checks at the
boundary:

<Tabs>
  <Tab title="Forst">
    ```ft theme={"theme":{"light":"github-light-default","dark":"dark-plus"}}
    type PlaceOrderInput = {
    	stockKeepingUnit: String.Min(1).Max(64),
    	quantity:         Int.Min(1).Max(99),
    }

    func placeOrder(in PlaceOrderInput) {
    	ensure in.stockKeepingUnit is Min(1).Max(64)
    	ensure in.quantity is Min(1).Max(99)
    	// business logic starts here
    }
    ```
  </Tab>

  <Tab title="Generated Go">
    ```go theme={"theme":{"light":"github-light-default","dark":"dark-plus"}}
    // forst build
    import (
    	errors "errors"
    	utf8 "unicode/utf8"
    )

    type PlaceOrderInput struct {
    	quantity         int
    	stockKeepingUnit string
    }

    func placeOrder(in PlaceOrderInput) error {
    	if utf8.RuneCountInString(in.stockKeepingUnit) < 1 || utf8.RuneCountInString(in.stockKeepingUnit) > 64 {
    		return errors.New("ensure in.stockKeepingUnit is String.Min(1).Max(64): want String.Min(1).Max(64)")
    	}
    	if in.quantity < 1 || in.quantity > 99 {
    		return errors.New("ensure in.quantity is Int.Min(1).Max(99): want Int.Min(1).Max(99)")
    	}
    	// business logic starts here
    	return nil
    }
    ```
  </Tab>

  <Tab title="Generated TypeScript">
    ```typescript theme={"theme":{"light":"github-light-default","dark":"dark-plus"}}
    // forst generate → @forst/gen
    export interface PlaceOrderInput {
      quantity: number;
      stockKeepingUnit: string;
    }
    ```
  </Tab>
</Tabs>

<Info>
  Forst is actively developed. Some features are experimental. See the [roadmap](/docs/resources/roadmap) for current status.
</Info>

## How it fits your stack

Forst compiles `.ft` sources to Go, and optionally emits TypeScript types for clients:

```mermaid theme={"theme":{"light":"github-light-default","dark":"dark-plus"}}
flowchart LR
  ft[".ft sources"]
  goOut["Generated Go"]
  deploy["go build / deploy"]
  dts["@forst/gen"]
  clients["API clients"]

  ft --> goOut --> deploy
  ft -.-> dts -.-> clients
```

Run `forst generate` when clients need TypeScript from the same source.

## Start here

<CardGroup cols={2}>
  <Card title="Why Forst?" icon="circle-question" href="/docs/why">
    Design priorities and what Forst omits.
  </Card>

  <Card title="Quickstart" icon="rocket" href="/docs/quickstart">
    Install, write your first `.ft` file, and run it.
  </Card>

  <Card title="Language overview" icon="book" href="/docs/language/overview">
    Go alignment, structural typing, and explicit control flow.
  </Card>

  <Card title="Describe a shape" icon="table-columns" href="/docs/language/shapes-and-constraints">
    Types as schemas with built in constraints.
  </Card>

  <Card title="Mix with Go packages" icon="https://mintcdn.com/forst/r5GJChnfkgCSJa-b/icons/golang.svg?fit=max&auto=format&n=r5GJChnfkgCSJa-b&q=85&s=e676ee132c42dfabaf125e76fe733c20" href="/docs/interop/go" width="205" height="77" data-path="icons/golang.svg">
    Import Go packages and mix `.ft` with `.go`.
  </Card>
</CardGroup>

## Examples and packages

* **Compiler examples:** [github.com/forst-lang/forst/tree/main/examples/in](https://github.com/forst-lang/forst/tree/main/examples/in)
* **npm compiler:** [`@forst/cli`](https://www.npmjs.com/package/@forst/cli)
* **Gradual adoption:** [`@forst/sidecar`](https://www.npmjs.com/package/@forst/sidecar) for invoking Forst from Node during migration

For client type generation, see [Generate client types](/docs/interop/invoke/generate-types).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.