Create React apps using Kotlin with no build configuration
Switch branches/tags
v1.0.7 v1.0.6 v1.0.5 v1.0.4 v1.0.3 v1.0.2 v1.0.1 v1.0.0 v0.9.5 v0.9.4 v0.9.3 v0.9.2 v0.9.1 v0.9.0 v0.8.5 v0.8.4 v0.8.3 v0.8.2 v0.8.1 v0.8.0 v0.7.0 v0.6.1 v0.6.0 v0.5.1 v0.5.0 v0.4.3 v0.4.2 v0.4.1 v0.4.0 v0.3.1 v0.3.0 v0.2.3 v0.2.2 v0.2.1 v0.2.0 v0.1.0 ts2kt-automator@1.0.5 ts2kt-automator@1.0.4 ts2kt-automator@1.0.3 ts2kt-automator@1.0.2 ts2kt-automator@1.0.1 ts2kt-automator@1.0.0 timer-react-scripts@0.7.1 react-scripts@1.0.7 react-scripts@1.0.6 react-scripts@1.0.5 react-scripts@1.0.4 react-scripts@1.0.3 react-scripts@1.0.2 react-scripts@1.0.1 react-scripts@1.0.0 react-scripts@0.9.5 react-scripts@0.9.4 react-scripts@0.9.3 react-scripts@0.9.1 react-scripts@0.9.0 react-scripts@0.8.5 react-scripts@0.8.4 react-scripts@0.8.3 react-scripts@0.8.2 react-scripts@0.8.1 react-scripts@0.8.0 react-scripts@0.7.0 react-scripts@0.6.1 react-scripts@0.5.0 react-scripts-kotlin@2.1.13 react-scripts-kotlin@2.1.12 react-scripts-kotlin@2.1.11 react-scripts-kotlin@2.1.10 react-scripts-kotlin@2.1.9 react-scripts-kotlin@2.1.8 react-scripts-kotlin@2.1.7 react-scripts-kotlin@2.1.6 react-scripts-kotlin@2.1.5 react-scripts-kotlin@2.1.4 react-scripts-kotlin@2.1.3 react-scripts-kotlin@2.1.2 react-scripts-kotlin@2.1.1 react-scripts-kotlin@2.1.0 react-scripts-kotlin@2.0.10 react-scripts-kotlin@2.0.9 react-scripts-kotlin@2.0.8 react-scripts-kotlin@2.0.7 react-scripts-kotlin@2.0.6 react-scripts-kotlin@2.0.5 react-scripts-kotlin@2.0.4 react-scripts-kotlin@2.0.3 react-scripts-kotlin@2.0.2 react-scripts-kotlin@2.0.1 react-scripts-kotlin@2.0.0 react-scripts-kotlin@1.0.9 react-scripts-kotlin@1.0.8 react-scripts-kotlin@1.0.7 react-scripts-kotlin@1.0.6 react-scripts-kotlin@1.0.5 react-scripts-kotlin@1.0.4 react-scripts-kotlin@1.0.3 react-scripts-kotlin@1.0.2 react-scripts-kotlin@1.0.1 react-scripts-kotlin@1.0.0
Nothing to show
Clone or download
TeamcityBuildserver Publish
 - create-react-kotlin-app@1.0.10
 - @jetbrains/gen-idea-libs@1.0.11
 - @jetbrains/kotlin-webpack-plugin@1.2.9
 - @jetbrains/kotlinc-js-api@1.2.9
 - react-scripts-kotlin@2.1.13
Latest commit baf821f Sep 14, 2018

README.md

Build Status JetBrains team project

Create React Kotlin App

Create React apps in Kotlin with no build configuration.

Please note that this is an early preview version.

Quick Overview

Make sure you have JDK 8 installed before proceeding. Java 9 is not supported yet.

Create a new project:

npx create-react-kotlin-app my-app

(npx comes with npm 5.2+ and higher. See Installation for older npm versions.)

Run the project:

cd my-app/
npm start

Then open http://localhost:3000/ to see your app.
When you’re ready to deploy to production, create a minified bundle with npm run build.

Create React Kotlin App will configure Kotlin, webpack, and IntelliJ IDEA so that you can focus on the code instead.

Just create a project, and you’re good to go.

Getting Started

Installation

Install it once globally:

npm install -g create-react-kotlin-app

You can skip this step if you have create-react-app already installed or you're using npx.

You’ll need to have Node >= 6 on your machine. You can use nvm to easily switch between Node versions for different projects.

This tool doesn’t assume a Node backend. The Node installation is only required for Create React Kotlin App itself.

Using React with Kotlin

To develop applications in Kotlin that use React you need to use a Kotlin wrapper for React. You can find a documentation for it and examples in the module's repository.

Adding Kotlin/JS packages

No configuration is required to add packages written in Kotlin to a project based on Create React Kotlin App, we take care of it for you. Simply run npm install kotlinx-coroutines-core to add https://www.npmjs.com/package/kotlinx-coroutines-core support, or npm install @jetbrains/kotlin-react-router-dom to install the wrapper for React Router DOM.

Creating an App

To create a new app, run:

create-react-kotlin-app my-app
cd my-app

Or if you have create-react-app installed, you can run:

create-react-app my-app --scripts-version react-scripts-kotlin
cd my-app

It will create a folder called my-app inside the current folder.
The project will be preconfigured for working with it in IntelliJ IDEA. If you don't want to create the .idea folder that is required for IntelliJ IDEA, add --no-idea option.
The initial project structure will be created and dependencies will be installed:

my-app/
  README.md
  node_modules/
  package.json
  .gitignore
  public/
    favicon.ico
    index.html
    manifest.json
  src/
    app/
      App.css
      App.kt
    index/
      index.css
      index.kt
    logo/
      kotlin.svg
      Logo.css
      Logo.kt
      react.svg
    ticker/
      Ticker.kt

It's a simple app that shows the time that passed since the app was opened.
Once the installation is done, you can run some commands inside the project folder:

npm start or yarn start

Runs the app in development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload automatically when you make edits.
You will see build errors and lint warnings in the console.

If you are getting a Kotlin.defineModule is not a function error, try deleting the npm cache:

rm -rf node_modules/.cache

npm run build or yarn build

Builds the app for production to the build folder.
It ensures that React is bundled in production mode and the build is optimized for best performance.

The build is minified and the filenames include hashes for cache management. Your app is ready to be deployed.

Debugging the App

You can debug the running app right in IntelliJ IDEA Ultimate using its built-in JavaScript debugger. The IDE will run a new instance of Chrome and attach a debugger to it.

Start your app by running npm start. Put the breakpoints in your Kotlin code. Then select Debug in Chrome from the list of run/debug configurations on the top-right and click the green debug icon or press ^D on macOS or F9 on Windows and Linux to start debugging.

Currently, debugging is supported only in IntelliJ IDEA Ultimate 2017.3.

You can also debug your application using the developer tools in your browser.

Philosophy

  • One Dependency: There is just one build dependency. It uses webpack and other amazing projects, but provides a cohesive curated experience on top of them.

  • No Configuration Required: You don't need to configure anything. Reasonably good configuration of both development and production builds is handled for you so you can focus on writing code.

  • No Lock-In: You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.

What’s Inside?

The generated project uses the following npm modules:

Why Use This?

With create-react-kotlin-app you can quickly bootstrap a new application using Kotlin and React. Your environment will have everything you need to build a new Kotlin app:

  • Kotlin and React syntax support.
  • A dev server that automatically compiles your Kotlin code to JavaScript.
  • A build script to bundle JavaScript, CSS, and images for production, with sourcemaps.

Limitations

  • Unit testing is currently not supported in this project. We're now working on the Jest Kotlin wrapper. Stay tuned!

Converting to a Custom Setup

You can “eject” from the tool and use it as a boilerplate generator.

Running npm run eject copies all configuration files and transitive dependencies (webpack, Kotlin Compiler, etc) right into your project so you have full control over them. Commands like npm start and npm run build will still work, but they will point to the copied scripts so you can tweak them. At this point, you’re on your own.

Note: this is a one-way operation. Once you eject, you can’t go back!

Contributing and reporting issues

Please report issues on YouTrack, GitHub issues are disabled for this project.

Contributions to this project are welcome! Please see the open issues or chat with us on the #react channel in our Slack.

Acknowledgements

This project is based on Facebook's Create React App. Many thanks to its authors for their work and inspiration.