Announcing [native.cr] โ€“ React Native for Crystal developers

After several months of work, I am releasing native.cr, a framework for building native mobile applications using the Crystal language.

Why?

I wanted to write mobile apps in Crystal. React Native proves cross-platform works, but JavaScript has performance limits. Flutter proves compiled cross-platform works, but Dart is not Crystal. Kotlin Multiplatform requires platform UI. Nothing fit.

So I built my own.

How it works

Crystal code compiles to ARM64 binaries for Android and iOS. No JavaScript bridge. No interpreter. No JSON serialization between threads.

  • Android: C engine + JNI + OpenGL ES
  • iOS: Objective-C bridge + Metal
  • Desktop preview: SDL2 + OpenGL (for development) still working on this

The framework includes UI components, styling, events, animations, networking, storage, camera, biometric auth, payments, audio, video, game loop, and gestures.

Code example

class MyApp < Native::App
  @[Preserve]
  property count : Int32 = 0

  def setup
    label = UI::Text.new
    label.text = "Tap: 0"

    button = UI::Button.new
    button.text = "Tap me"
    button.on_click = ->{ increment(label) }

    column = UI::Column.new
    column.spacing = 16
    column.add_child(label)
    column.add_child(button)

    @root = column
  end

  def increment(label)
    @count += 1
    label.text = "Tap: #{@count}"
  end
end

Native::App.start(MyApp)

Current status

  • All core UI components working
  • Android build produces .so library
  • iOS build produces .framework
  • Desktop preview via SDL2
  • State preservation across fast restarts
  • 24 framework modules complete

Installation

git clone https://github.com/slick-lab/native.cr
cd [native.cr](http://native.cr/)
shards install
shards build
sudo cp bin/[native.cr](http://native.cr/) /usr/local/bin/

Create a project

native.cr create my_app
cd my_app
native.cr build android

What remains

  • Full APK packaging (user handles via Android Studio for now)
  • iOS simulator integration
  • More examples

Links

The project needs help with:

  • Android NDK build automation
  • iOS simulator integration
  • Documentation and examples
  • Testing on different devices

The codebase is ~10,000 lines. Crystal knowledge required. C/Objective-C knowledge helpful.

License

MIT


I welcome questions, feedback, and pull requests.

6 Likes