- Notifications
You must be signed in to change notification settings - Fork122
Create React apps using Kotlin with no build configuration
License
JetBrains/create-react-kotlin-app
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
CreateReact apps inKotlin with no build configuration.
Please note that this is anearly preview version.
Make sure you haveJDK 8 or newer version installed before proceeding.
Create a new project:
npx create-react-kotlin-app my-app
(npx comes with npm 5.2+ and higher. SeeInstallation for older npm versions.)
Run the project:
cd my-app/npm startThen openhttp://localhost:3000/ to see your app.
When you’re ready to deploy to production, create a minified bundle withnpm 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.
Install it once globally:
npm install -g create-react-kotlin-app
You can skip this step if you havecreate-react-app already installed or you're usingnpx.
You’ll need to have Node >= 6 on your machine. You can usenvm 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.
To develop applications in Kotlin that use React you need to use aKotlin wrapper for React.You can find a documentation for it and examples in themodule's repository.
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.For example, you can simply runnpm install @jetbrains/kotlin-react-router-dom to install thewrapper for React Router DOM.
To create a new app, run:
create-react-kotlin-app my-appcd my-appOr if you havecreate-react-app installed, you can run:
create-react-app my-app --scripts-version react-scripts-kotlincd my-appIt will create a folder calledmy-app inside the current folder.
The project will be preconfigured for working with it inIntelliJ 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.ktIt'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:
Runs the app in development mode.
Openhttp://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 aKotlin.defineModule is not a function error, try deleting the npm cache:
rm -rf node_modules/.cacheBuilds the app for production to thebuild 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.
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 runningnpm start. Put the breakpoints in your Kotlin code.Then selectDebug in Chrome from the list of run/debug configurations on the top-right and click the green debug icon or press^D on macOS orF9 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.
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.
The generated project uses the following npm modules:
- Kotlin wrappers:@jetbrains/kotlin-react,@jetbrains/kotlin-react-dom,@jetbrains/kotlin-extensions
- Kotlin DSL for HTML
- Kotlin Compiler
- webpack withwebpack-dev-server,@jetbrains/kotlin-webpack-plugin,html-webpack-plugin andstyle-loader
- and others.
Withcreate-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
buildscript to bundle JavaScript, CSS, and images for production, with sourcemaps.
- Unit testing is currently not supported in this project. We're now working on the Jest Kotlin wrapper. Unit-testing React is tracked inKT-49610. Stay tuned!
You can “eject” from the tool and use it as a boilerplate generator.
Runningnpm 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 likenpm start andnpm 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 youeject, you can’t go back!
Please report issues onYouTrack, GitHub issues are disabled for this project.
Contributions to this project are welcome! Please see the openissues or chat with us on the#react channel in ourSlack.
This project is based on Facebook'sCreate React App. Many thanks to its authors for their work and inspiration.
About
Create React apps using Kotlin with no build configuration
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.