by hussachai

Play+Scala.js Showcase

125 Stars 44 Forks Last release: Not found Do What The F*ck You Want To Public License 138 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Play Framework with Scala.js Showcase

Scala: 2.11.6, Scala.js: 0.6.5, Play: 2.4.0, Slick: 3.0.0

Update: July 2016

This project was started on Oct 2014 when Scala.js was still an experimental project. I didn't expect Scala.js to come this far because there were a lot of Scala projects that were discontinued. Surprisingly, it's not just still alive but keeps growing. I have to catch up what I missed for almost 2 years, and start looking for something cool to learn as usual.(Stay hungry, still foolish LoL)
I'm looking forward to using this:
The new version I plan in my head is to use React and Microservice.

This is a small application showing how cool Scala.js is. You can share code across platforms. For the shared code, the Scala compiler compiles your Scala code to JVM byte code, and the ScalaJS compiler compiles the same Scala code to JavaScript. Beside CSS and a few lines of HTML, almost all code in this project are type-safety including HTML (Thanks to scalatags). I made this project for learning purpose during my summer intern. So, the code you will see in this project may look not good, but I hope you can learn something from it like I did. ~~I will try to keep it update-to-date to make sure that it will run with the recent version of Scala.js.~~

The sbt build file contains 3 modules -

Play application (server side) -
Scala.js application (client side) -
Scala code that you want to share between the server and the client.

This project would not exist if I didn't find this kick-ass example play-with-scalajs-example.

The project contains 4 simple examples:

  • Todo application with backend persistence.(Modified from Todo application)
    • InMemory, Slick, Anorm, Gremlin (Selectable in application.conf)
  • Hangman (Inspired by Yii's demo)
  • HTML5 Fileupload (Modified from How to Use HTML5 File Drag and Drop)
  • Server Push Chat. It supports both Websocket and Server-Sent Event

Prerequisite steps

Before running the application, you may need to do these steps: 1. Add the folowing to ~/.sbt/0.13/plugins/plugins.sbt

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

Run the application

$ sbt
> run
$ open http://localhost:9000

Run the application on heroku

  • Install the heroku toolbelt
  • Run following commands:
    $ heroku login
    $ heroku create
    $ git push heroku master
    $ heroku open


The application uses the sbt-play-scalajs sbt plugin and the play-scalajs-scripts library.

  • Run your application like a regular Play app
    • compile
      simply triggers the Scala.js compilation
    • run
      triggers the Scala.js fastOptJS command on page refresh
    • ~compile
      , continuous compilation is also available
    • start
      generate the optimised javascript
    • playscalajs.html.scripts
      selects the optimised javascript file when the application runs in prod mode (
  • Source maps
    • Open your browser dev tool to set breakpoints or to see the guilty line of code when an exception is thrown
    • Source Maps is disabled in production by default to prevent your users from seeing the source files. But it can easily be enabled in production too by setting
      emitSourceMaps in fullOptJS := true
      in the Scala.js projects.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.