Tyrian, an Elm inspired frontend framework for Scala.js.

Installation

Quick Setup with Giter8

You can create an sbt based Tyrian project and have it up and running in less than 5 minutes!*

From your command line, create a folder for your project, navigate into it, and run:

sbt new PurpleKingdomGames/tyrian.g8

Then follow the instructions in the README file.

(* Probably, if you have sbt and npm/yarn already installed... 😅)

Installation

Tyrian is a Scala 3 Web UI library, so please set your Scala version to 3.3.1 or higher.

You can use Tyrian with Scala 2 thanks to cross versions and the magic of TASTy.

Please note that both the sbt and Mill instructions below assume you intend to work with some sort of web packager/bundler, and therefore emit common js modules.

The examples in the Tyrian repo almost all use Parcel.js as the bundler.

sbt

Add the Scala.js plugin to your project/plugins.sbt file.

addSbtPlugin("org.scala-js" % "sbt-scalajs"  % "1.15.0")

Enable the plugin and add the Tyrian library to your build.sbt file.

enablePlugins(ScalaJSPlugin)

libraryDependencies ++= Seq(
  "io.indigoengine" %%% "tyrian-io" % "0.10.0"
  // OR
  "io.indigoengine" %%% "tyrian-zio" % "0.10.0"
)

scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }

Optionally, you can also include the Tyrian/Indigo Bridge library if you plan to embed an Indigo game in your page:

libraryDependencies ++= Seq(
  ...
  "io.indigoengine" %%% "tyrian-indigo-bridge" % "0.10.0"
)

Mill

Below is a complete, basic Mill build.sc file including MUnit for testing.

import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION`
import mill._
import mill.scalalib._
import mill.scalajslib._
import mill.scalajslib.api._

object counter extends ScalaJSModule {
  def scalaVersion   = "3.3.1"
  def scalaJSVersion = "1.15.0"

  def ivyDeps = Agg(ivy"io.indigoengine::tyrian::0.10.0")

  override def moduleKind = T(mill.scalajslib.api.ModuleKind.CommonJSModule)

  object test extends Tests {
    def ivyDeps = Agg(ivy"org.scalameta::munit::0.7.29")

    def testFramework = "munit.Framework"

    override def moduleKind = T(mill.scalajslib.api.ModuleKind.CommonJSModule)
  }

}

Optionally, you can also include the Tyrian/Indigo Bridge library if you plan to embed an Indigo game in your page:

  def ivyDeps = Agg(
    ivy"io.indigoengine::tyrian::0.10.0",
    ivy"io.indigoengine::tyrian-indigo-bridge::0.10.0"
  )