Overview
The Scala 3 / NextJS Starter is a template that combines the Scala 3 programming language with the Next.js framework and Tailwind CSS. It provides a Next.js web application using Scala 3 and scalajs-react, with full Tailwind v2 configuration and additional features like the NextApp sbt plugin for adding more Next.js sub-projects if needed. It also includes a server sbt project for server-side logic and a shared sbt project for code sharing between the Next.js app and the back end.
Features
- Next.js web application using Scala 3 and scalajs-react
- Full Tailwind v2 configuration with autoprefixer, purge-css, and cssnano
- NextApp sbt plugin for adding more Next.js sub-projects
- Server sbt project for server-side logic, preconfigured with sbt-revolver
- Shared sbt project for code sharing between Next.js app and back end (e.g., Tapir endpoints)
Installation
To set up the Scala 3 / NextJS Starter, follow these steps:
Install node dependencies:
npm installAlternatively, you can run it directly from sbt, from the root repository:
sbt;project root;npmInstallNote: Running external commands from sbt may be slower than running them from a terminal.
Launch the Next.js development server:
npm run devAlternatively, if you prefer to run everything from sbt, the NextApp plugin provides several sbt commands:
startNextServerto start the development server in the background. Does nothing if the server is already running.stopNextServerto stop the development server.show nextServerIsRunningto check if the development server is running.
Build the JavaScript from Scala.js and watch for changes. Run the following command in another terminal:
sbt;project frontend;~fastOptJSFor production build, follow these steps:
Build the JavaScript from Scala.js with full optimization:
sbt;project frontend;fullOptJSBuild the Next.js app:
npm run build
Alternatively, you can run the production build from sbt using the following command:
sbt;project root;deploy
Summary
The Scala 3 / NextJS Starter is a template that combines the Scala 3 programming language, Next.js framework, and Tailwind CSS to provide a convenient starting point for developing web applications. It offers features like a Next.js web application using Scala 3 and scalajs-react, full Tailwind v2 configuration, and plugins for managing Next.js sub-projects and server-side logic. The installation process involves setting up node dependencies, launching the development server, and building the JavaScript from Scala.js. Overall, this template aims to simplify the development process while leveraging the capabilities of Scala 3, Next.js, and Tailwind CSS.