DocsPlaygroundBlogCommunity
  • Playground
  • Blog
  • Community
  • X
  • Bluesky
  • GitHub
  • Forum
Language ManualAPISyntax LookupReact
Language Manual
Overview
  • Introduction
    • Part of the JavaScript ecosystem
    • Type System
    • Compiler
  • Installation
  • Editor
  • LLMs
Guides
  • Converting from JS
  • Dead Code Analysis in ReScript
  • Project Structure
JavaScript Interop
  • Interop Cheatsheet
  • Embed Raw JavaScript
  • Shared Data Types
  • External (Bind to Any JS Library)
  • Bind to JS Object
  • Bind to JS Function
  • Import from / Export to JS
  • Bind to Global JS Values
  • JSON
  • Inlining Constants
  • Use Illegal Identifier Names
  • Generate Converters & Helpers
  • Browser Support & Polyfills
  • Libraries & Publishing
  • TypeScript
Language Features
  • Overview
  • Let Binding
  • Type
  • Primitive Types
  • Tuple
  • Record
  • Object
  • Dictionary
  • Variant
  • Polymorphic Variant
  • Null, Undefined and Option
  • Array & List
  • Function
  • If-Else & Loops
  • Pipe
  • Pattern Matching / Destructuring
  • Mutation
  • JSX
  • Exception
  • Lazy Value
  • Promises
  • Async / Await
  • Tagged templates
  • Module
  • Import & Export
  • Attribute (Decorator)
  • Reserved Keywords
  • Equality and Comparison
Build System
  • Overview
  • Configuration
  • Configuration Schema
  • External Stdlib
  • Pinned Dependencies
  • Interop with JS Build Systems
  • Performance
  • Warning Numbers
Advanced Features
  • Extensible Variant
  • Scoped Polymorphic Types
Docs / Language Manual / Introduction
Edit

You are currently looking at the v12 docs, which are still a work in progress. If you miss anything, you may find it in the older v11 docs here.

ReScript

ReScript is a robustly typed language that compiles to efficient and human-readable JavaScript. It comes with a lightning fast compiler toolchain that scales to any codebase size.

Part of the JavaScript ecosystem

ReScript looks like JS, acts like JS, and compiles to the highest quality of clean, readable and performant JS, directly runnable in browsers and Node. This means you can pick up ReScript and access the vast JavaScript ecosystem and tooling as if you've known ReScript for a long time!

You don't need to learn new package managers, bundlers, frameworks, or testing libraries. All of the knowledge you have about doing web development with JavaScript can be applied to building applications with Rescript.

ReScript code can be imported into JavaScript code, can generate types for TypeScript, and ReScript can import code written in JavaScript or TypeScript.

Type System

  • Is deliberately curated to be a simple subset most folks will have an easier time to use.

  • Has no pitfalls, aka the type system is "sound" (the types will always be correct). E.g. If a type isn't marked as nullable, its value will never lie and let through some undefined value silently. ReScript code has no null/undefined errors.

  • Is the same for everyone. No knobs, no bikeshedding opportunity.

  • Runs extremely fast precisely thanks to its simplicity and curation. It's one of the fastest compiler & build system toolchains for JavaScript development.

  • Doesn't need type annotations. Annotate as much or as little as you'd like. The types are inferred by the language (and, again, are guaranteed correct).

Compiler

Compiles to Optimized JavaScript

JavaScript's been aggressively optimized by talented engineers over a long span. Unfortunately, even for seasoned JS devs, it can be hard to know how to properly leverage JS's performance. ReScript's type system and compiler naturally guides you toward writing code that's very often performant by default, with good leverage of various Just-In-Time optimizations (hidden classes, inline caching, avoiding deopts, etc).

A widespread adage to write fast JavaScript code is to write as if there's a type system (in order to trigger JS engines' good optimization heuristics); ReScript gives you a real one and generates code that's friendly to optimizations by default.

Tiny JS Output

A Hello world ReScript program generates 20 bytes of JS code. Additionally, the standard library pieces you require in are only included when needed.

Fast Iteration Loop

ReScript's build time is one or two orders of magnitude faster than alternatives. In its watcher mode, the build system usually finishes before you switch screen from the editor to the terminal tab (two digits of milliseconds). A fast iteration cycle reduces the need of keeping one's mental state around longer; this in turn allows one to stay in the flow longer and more often.

Readable Output

ReScript's JS output is very readable. This is especially important while learning, where users might want to understand how the code's compiled, and to audit for bugs.

This characteristic, combined with a fully-featured JS interop system, allows ReScript code to be inserted into an existing JavaScript codebase almost unnoticed.

Preservation of Code Structure

ReScript maps one source file to one JavaScript output file. This eases the integration of existing tools such as bundlers and test runners. You can even start writing a single file without much change to your build setup. Each file's code structure is approximately preserved, too.

High Quality Dead Code Elimination

The JavaScript ecosystem is very reliant on dependencies. Shipping the final product inevitably drags in a huge amount of code, lots of which the project doesn't actually use. These regions of dead code impact loading, parsing and interpretation speed. ReScript provides powerful dead code elimination at all levels:

  • Function- and module-level code elimination is facilitated by the well-engineered type system and purity analysis.

  • At the global level, ReScript generates code that is naturally friendly to dead code elimination done by bundling tools such as Rollup and Closure Compiler, after its own sophisticated elimination pass.

  • The same applies for ReScript's own tiny runtime (which is written in ReScript itself).

Installation

© 2025 The ReScript Project

Software and assets distribution powered by KeyCDN.

About
  • Community
  • ReScript Association
Find us on