@p Historically, sharing code across client & server has been a holy-grail for web development. There are many things which have made it hard in the past: @ul @li Javascript on the client v.s. PHP/Perl/Python/Ruby/Java on the client @li Most back-ends make heavy use of C extensions, and front-end code was tightly coupled to the DOM. Even if you manage to port the main language @p There have been some attempts in recent years with more traction: Node.js, for example, has been very successful at running Javascript on the server, the Clojure/Clojurescript community has their own version of cross-built code, and there are a number of smaller, more esoteric platforms. @p Scala.js lets you share code between client and server relatively straightforwardly. As we saw in the previous chapter, where we made a shared module. Let's work to turn that shared module into a working client-server application! @sect{Client-Server Configuration} @p Getting started with client-server integration, let's go with the simplest configuration possible: a Spray server and a Scala.js client. Most of the other web-frameworks (Play, Scalatra, etc.) will have more complex configurations, but the basic mechanism of wiring up Scala.js to your web framework will be the same. @p First, let's do the wiring in @code{build.sbt} to add Spray as a dependency, @hl.ref("examples/crossBuilds/clientserver/build.sbt") @p This does the standard boilerplate for including dependencies via SBT, and does on additional thing: we add the output of @code{fastOptJS} from the client to the @code{resources} on the server. @p Next, let's kick off the Spray server in our Scala-JVM main method: @hl.ref("examples/crossBuilds/clientserver/jvm/src/main/scala/simple/Platform.scala") @p This is a not-very-interesting @a("spray-routing", href:="http://spray.io/documentation/1.2.2/spray-routing/") application: we set up a server on @code{localhost:8080}, have the root URL serve a HTML string, and have other URLs serve resources. This includes the @code{js-fastopt.js} file that is now in our resources because of our @code{build.sbt} config earlier! We also add a POST route to allow the client ask the server to format dates any time it wants via Ajax. @p Lastly, we'll set up the Scala.js main method, which we are calling in the @hl.html{