gleam-javascript-interop

Integrate Gleam with JavaScript using FFI and @external functions.

3|1|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/renatillas/gleam --skill gleam-javascript-interop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gleam-javascript-interop
Source: https://github.com/renatillas/gleam/tree/main/skills/gleam-javascript-interop
Command: npx skills add https://github.com/renatillas/gleam --skill gleam-javascript-interop

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides Claude through integrating Gleam with JavaScript code using FFI, externals, and NPM packages, enabling calling JavaScript from Gleam and leveraging existing libraries with type safety.

Core Features & Use Cases

  • External function bindings: declare @external to call JavaScript functions from Gleam, with precise type mappings.
  • NPM and ESModule interop: wrap and consume existing JavaScript libraries inside Gleam projects.
  • Browser API access: build Gleam applications that interact with DOM or fetch APIs via JavaScript glue code.

Quick Start

Install Gleam and Node.js, create a new Gleam project, write a minimal JS bridge in an .mjs file, declare an external function in Gleam with @external, then build for the JavaScript target and run the output with Node.js.

Frequently Asked Questions about gleam-javascript-interop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call JavaScript functions from Gleam?

To call JavaScript functions from Gleam, declare external functions using the @external attribute and map Gleam types to JavaScript types in a .mjs module. This provides type-safe bindings for your JavaScript code.

Can I use NPM packages in a Gleam project targeting JavaScript?

Yes, you can consume NPM packages in a Gleam project by wrapping the JavaScript libraries in ES modules and importing them via FFI. This allows you to leverage existing JavaScript libraries with type safety.

What is the best way to access browser APIs from Gleam?

Accessing browser APIs from Gleam requires writing JavaScript glue code in .mjs files and exposing it through external function declarations. This bridges Gleam applications with DOM or fetch APIs securely.

Do I need Node.js and npm to build Gleam projects for the JavaScript target?

Yes, building Gleam projects for the JavaScript target requires the Gleam toolchain alongside Node.js with npm. These tools are necessary to compile Gleam, resolve dependencies, and execute the output modules.

How does Gleam FFI maintain type safety when interfacing with JavaScript?

Gleam FFI maintains type safety through the @external syntax, which enforces precise type mappings between Gleam and JavaScript. This ensures that JavaScript functions called from Gleam adhere to expected type contracts.