js marker tells Forst that this path points to a JavaScript module. The compiler checks the function name, arguments, and return value. Every call returns a Result, so ensure result is Ok() handles failures before you use the value.
At runtime, the compiled app starts a local bridge process when it first runs a JS import call. If your program does not use a JS import, the compiled binary does not need JavaScript.
Set up JavaScript imports
Install@forst/runtime in your project root.
ftconfig.json.
js marker. Plain imports never start the JS bridge.
Import a module
Use the file name as the local name, or choose an alias.
You can also group imports together.
payment.create calls the create export. Your TypeScript files need no special Forst annotations.
Alias reserved names
When the file or package name matches a Forst or Go keyword, Forst reports an error and asks for an alias.
Scoped npm packages like
@effect/platform default to the last path segment (platform) when that name is valid.
Call synchronous functions
Synchronous JavaScript functions look like normal calls in Forst. The result is wrapped inResult(T, Error) because the local IPC call can still fail.
Use ensure … is Ok() or if … is Err() before reading the returned value.
Call asynchronous functions
You can call an async JavaScript function from normal Forst code. The bridge waits for the Promise to settle and returns its value. You do not addasync or await to your Forst code.
Separate system errors from return values
Two different things can fail during a call. The bridge runtime itself can fail, or your JavaScript function can return an error value.
If an async JavaScript function resolves to a tagged union, Forst maps that union as
T. The outer return type remains Result(T, Error).
Read streams and generators
JavaScript generator functions appear asSeq[T] in Forst. Check that the generator opened successfully, then use a for range loop to read items.
Seq[T]. The bridge pulls items in batches to cut IPC round trips.
Next steps
- Build, deploy, and runtime modes compile modules and configure runtime hosts