Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Opinionated boilerplate for NextJS, Tailwind, and ReScript with preconfigured bindings and Fast Refresh support.
The ReScript NextJS Starter is an opinionated boilerplate that combines Next.js, Tailwind CSS v2, and the ReScript compiler to give you a preconfigured setup for building React apps in ReScript.
This template provides a starting point for projects that use Next.js as the React framework, Tailwind CSS for styling, and ReScript (a typed language compiling to JavaScript) for application logic. It outputs a Next.js application with ReScript compiled to .mjs files (ES6 modules) and includes basic ReScript bindings for Next.js APIs. It is maintained by a ReScript core team member and was created from learnings of building the ReScript Documentation Platform.
@rescript/react dependency and compiles ReScript to ES6 .mjs files..resi) for each page, or re-exporting components through plain pages/*.js files to keep Fast Refresh always working..bs.js suffixes instead of ES6 .mjs.pages/blog/[slug].res but notes you cannot import these modules elsewhere due to ReScript module syntax limitations.npm run res:start and npm run dev in separate tabs, and get hot-reload development.npx postcss styles/main.css -o test.css in dev or production mode..bs.js files.The development workflow runs two processes: npm run res:start watches and compiles ReScript files, while npm run dev starts the Next.js dev server. For production, you build with npm run build (after uncommenting the target attribute in now.json) and serve with PORT=3001 npm start.
.mjs files tracked in git?Tracking compiled JavaScript output lets you sanity-check whether changes to ReScript code actually affect the generated JS, especially during major compiler upgrades. It also helps non-ReScript teammates review changes in pull requests; to opt out, remove the src mjs files and add src/**/*.mjs to your .gitignore.
It was created through building the ReScript Documentation Platform, which itself runs on Next.js, and is maintained by one of the ReScript core team members. Updates are irregular and driven by demand, such as important changes in the Next.js bindings or dependencies.
You can create files like pages/blog/[slug].res, but you cannot reference those modules inside other modules because ReScript has no syntax for brackets in module paths. You also need an accompanying .resi interface file to comply with Fast Refresh rules.
Make sure you only export React components from files in the pages directory, and create .resi interface files for each page/*.res file. The recommended always-works approach is to put ReScript components in src and re-export them in plain pages/*.js files.
Set package-specs to use commonjs with in-source: true and suffix .bs.js, then replace the src/MyResFile.mjs import paths in pages with the .bs.js counterpart. This template defaults to ES6 .mjs output.
