Getting Started

Installation

using Pkg
Pkg.add(url="https://github.com/GroupTherapyOrg/JavaScriptTarget.jl")

Basic Usage

Write a Julia function with typed arguments, then transpile to JavaScript:

using JavaScriptTarget

function add(a::Int32, b::Int32)::Int32
    return a + b
end

result = compile(add, (Int32, Int32))
println(result.js)
# Output: function add(a, b) { return (a + b) | 0; }

Type Mappings

Julia types map naturally to JavaScript. This table shows the core type mappings — see the full API reference for comprehensive coverage of 80+ supported operations across math, strings, arrays, broadcasting, structs, and more.

JuliaJavaScript
Int32, Int64number | 0
Float64number
Stringstring
Boolboolean
Vector{T}Array
Matrix{T} (ND arrays)Nested Array: [[row1], [row2]]
Dict{K,V}Map
Set{T}Set
structES6 class
TupleArray
Nothingnull

With Therapy.jl

JST powers Therapy.jl's @island components. Write Julia → JST transpiles to inline JS → browser hydrates.

using Therapy

@island function Counter(; initial::Int = 0)
    count, set_count = create_signal(initial)
    return Div(
        Button(:on_click => () -> set_count(count() + 1), "+"),
        Span(count)
    )
end
# → Transpiles to ~500 bytes of inline JavaScript