spin-moonbit-sdk

    Experimental Spin SDK for the MoonBit programming language.

    spin
    moonbit
    sdk
    Download zip
    Author
    Version
    0.55.1
    License
    Apache-2.0
    Last updated
    1 hour ago
    Downloads
    1K

    Dependencies

    #gmlewis/spin-moonbit-sdk

    check

    This is an experimental Spin SDK for the MoonBit programming language. Please expect breaking changes while still experimenting with the API.

    This is based on this blog post: https://www.moonbitlang.com/blog/component-model and this GitHub example: https://github.com/moonbitlang/moonbit-docs/tree/464356567270284446244cccecd101c04e9806f8/examples/wasi-http

    #Templates

    If you wish to install MoonBit templates for the Spin CLI tool (v3), you can run:

    spin templates install --git https://github.com/gmlewis/spin-moonbit-sdk

    The templates are located in the templates folder.

    #Build (SDK Development)

    Before building, you must have already installed the MoonBit programming language and the Spin CLI tool. You also need version v1.236.0 or later of wasm-tools.

    To install MoonBit, follow the instructions here (it is super-easy with VSCode): https://www.moonbitlang.com/download/

    If you already have the Rust programming language installed, you can install wasm-tools by typing:

    cargo install --locked wasm-tools

    Then, to build this SDK, clone the repo, and type:

    moon update moon build

    #Examples

    Examples can be found at: https://github.com/gmlewis/spin-moonbit-sdk-examples

    To run an example, type:

    $ cd examples/hello-world $ spin up --build

    then from another terminal, hit the endpoint with curl:

    $ curl -i localhost:3000/hello HTTP/1.1 200 OK content-type: text/plain transfer-encoding: chunked date: Sat, 17 Aug 2024 00:15:14 GMT Hello, World!

    Each example contains a README. Please refer to the README for additional commands and setup instructions. It might also be required to issue an update command: moon update to retrieve the latest dependencies.

    #Regenerating the bindings

    The WIT bindings under interface/, gen/, and ffi/ are generated, not hand-written. To regenerate them after editing anything under wit/:

    $ cd wit $ ./run-wit-bindgen.sh

    That script is a thin wrapper around cmd/wit-translate, which drives wit-bindgen (installed via cargo install wit-bindgen-cli) and then reshapes its output into the layout documented inside that Go program. Note that wit-bindgen still emits the long-deprecated moon.mod.json / moon.pkg.json manifests; the wrapper lets the current moon compiler migrate those to moon.mod / moon.pkg rather than reimplementing the migration.

    #Status

    The code has been updated to support compiler:

    $ moon version --all moon 0.1.20260904 (94521db 2026-09-04) ~/.moon/bin/moon moonc v0.10.12+1634b282e (2026-09-07) ~/.moon/bin/moonc moonrun 0.1.20260904 (94521db 2026-09-04) ~/.moon/bin/moonrun and generator: ```bash $ wit-bindgen --version wit-bindgen-cli 0.62.0 (c604ee01c 2026-09-10)

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io