Spring I/O: Isomorphic React applications with Nashorn and Spring Boot

Isomorphic web apps – where the backend and frontend share the same code – are all the rage nowadays. With them, you render the page on the server with the same code which is used on the client. This gives the advantages of for example quickly loading pages, SEO, and less code.

But Spring hasn’t had the same kind of support for this technique as node.js, which made a user raise an issue here: https://jira.spring.io/browse/SPR-12266

This was picked up by Sébastien Deleuze, who then implemented support for Javascript templating to Spring MVC. There are still some things to improve, but as far as I can see they will be fixed quite soon.

Sébastien held a presentation where he showed a demo which really made me want to go home and try it out!

His solution supports not only Javascript rendering engines, but all JSR-223 engines: JRuby, Jython, Nashorn (Rhino is too slow to be useful for this)

What you have to do to get this to work is:

  • define a bean of type ScriptTemplateViewResolver which points to your template directory
  • define a ScriptTemplateConfigurer with the desired script engine (‘nashorn’, for example), and which scripts to load.

This makes Spring render the template using Nashorn and React (if you told it to load that script).

If you thought this was maybe a bit too little information, check out the slides and sample projects:

Isomorphic React application: https://github.com/sdeleuze/spring-react-isomorphic

…and another using Handlebars as template engine: https://github.com/sdeleuze/spring-boot-sample-web-handlebars

Slides:

https://speakerdeck.com/sdeleuze/isomorphic-templating-with-spring-boot-nashorn-and-react

The presentation was recorded, but hasn’t been uploaded yet. I’ll update this post when it is!


A Holistic View on Developer Productivity

What does developer productivity mean, really? Is it churning out more code or less code? Is it to have less bugs in production or shipping code more often? Is it doing a lot of things or just one thing? Let’s think about this for a moment. I believe developer productivity is about getting more things […]


Improving the usability of Aftonbladet Video-clip pages

We have recently started the process of improving the usability of video-clip pages. In order to get an idea of where Aftonbladet stands compared to other world-class online video/news providers, we conducted an online test answered by 110 visitors of Aftonbladet TV. In this test we compared their perception of an Aftonbladet TV video-clip page […]


Schibsted’s 1st iOS Deployment Meet-up

Schibsted’s 1st iOS Deployment Meet-up Thursday, 28th of April 2016: getting to know each other, guests arrive Friday, 29th of April 2016: the meet-up date We here at Aftonbladet had been planning on having a meet-up with iOS developers across various Schibsted companies for many months. We had a range of topics in mind for […]


Hackday: The Future of Storytelling is social, engaging and rewarding

We gathered students, journalists, developers and designers to get together and conceptualize something new for the news industry. This was our first organized hack event – The Future of Storytelling Hack. The hack was a team-based, news-media-focused prototyping and experimentation event within storytelling over two days at Kungsbrohuset, Schibsted and Aftonbladets headquarter in Stockholm. A good story used to […]