> ## 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.

# Overview

> Call legacy TypeScript and JavaScript from compiled Forst binaries.

Forst can call functions from existing TypeScript and JavaScript modules while your app runs.
We call this bridge internally. The Go program starts a JavaScript bridge process and talks to it over a local socket. The bridge process runs `@forst/runtime` to load your modules and run function calls.

Use the `js` import suffix, enable bridge in `ftconfig.json`, and install `@forst/runtime` in your project.

```ft theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/languages/forst.json"]}}
import "./legacy/payment" js

func main() {
  result := payment.create(100.0, "USD")
  ensure result is Ok()
  println(result.id)
}
```

## Start here

| Goal                                       | Guide                                                                 |
| ------------------------------------------ | --------------------------------------------------------------------- |
| Import modules and call functions          | [Import and call JavaScript](/docs/interop/bridge/import-and-calls)        |
| Build binaries and configure runtime hosts | [Build, deploy, and runtime modes](/docs/interop/bridge/build-and-runtime) |
| Security model and threat analysis         | [Bridge security](/docs/interop/bridge/security)                           |
| Call Forst over HTTP (opposite direction)  | [Call Forst over HTTP](/docs/interop/invoke/call-forst)                    |
| Share types only                           | [Generate client types](/docs/interop/invoke/generate-types)               |

## Configuration summary

Enable the bridge in `ftconfig.json`.

```json theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/languages/forst.json"]}}
{
  "bridge": {
    "enabled": true,
    "importPolicy": "explicit",
    "runtimeEnabled": true,
    "host": "node",
    "legacyModules": {
      "format": "compiled",
      "precompile": { "outDir": ".forst/js" }
    }
  }
}
```

Set `bridge.host` to `node`, `bun`, or `deno`. Use environment variables to override host settings at deploy time.

## Related

<CardGroup cols={2}>
  <Card title="JavaScript interop hub" icon="https://mintcdn.com/forst/r5GJChnfkgCSJa-b/icons/typescript.svg?fit=max&auto=format&n=r5GJChnfkgCSJa-b&q=85&s=8a8c0cd7b4bf60c264d51f66d0f52e91" href="/docs/interop/invoke" width="512" height="512" data-path="icons/typescript.svg">
    Typed client generation and calling Forst from Node.
  </Card>

  <Card title="Bridge interop examples" icon="code" href="https://github.com/forst-lang/forst/tree/main/examples/in/rfc/bridge-interop">
    Runnable code examples for sync, async, generators, and host mode.
  </Card>
</CardGroup>
