Recommendations for new full stack ReScript project

I’m exploring using ReScript for a new project and I’d greatly appreciate any advice you can provide.

Server side

I am currently planning for Node.js server side (using Express or Next) and React client side.

I have no experience with OCaml at all or it’s ecosystem.

As I lack OCaml experience, can you see any problem with developing the project server side in ReScript compiled to JS?

Client side

I am planning to develop the client side with ReasonReact.

Project structure

As I’m new to the ReScript I don’t currently have any plan for how to structure the project, so I’d be grateful if you could point me to an example repo that I could use as a starting point.

Thanks for any guidance you can provide.

2 Likes

My main gripes so far is not that you can’t write all your server side code in Rescript (you totally can cuz of its easy JS interop), but you don’t get code completion yet with the vscode plugins. Maybe that’s changed within the month.

If you’re asking for “structure” or file organization as many sometimes do, I’d advise to worry about that a little later on. Following any common Express and React architecture is good enough to start: routes, controllers, services (for database and 3rd party integrations).

Write the code that gets your things done. Then clean up the code, separating functions into modules (new files or within files) for better encapsulation.

If you’re going to layer ReScript on top of Express or Next, then you’d first want to make sure you have all the bindings ready or learn how to write them yourself. For example, use bs-express to save yourself some time.

Here’s a great template to start off with Next https://github.com/ryyppy/rescript-nextjs-template

3 Likes

Great, thanks @dangdennis

Curious about pros and cons of using bsb starter for reason vs rescript-nextjs-template, if anybody has any experience contrasting them already.

If you remove rescript from the equation, you have a super barebones react app vs a complete react framework.

Your choice there.

1 Like

For the server side, here is an example project structure based on a functional pattern: https://github.com/swlaschin/Railway-Oriented-Programming-Example/tree/master/src/FsRopExample

F# is based on Ocaml, so the syntax is very similar to Ocaml, and the same concepts apply.

2 Likes

Just thought I’d mention this for other people like me coming by this post:
Full-stack ReScript. Architecture Overview

More, here: awesome-rescript

2 Likes

I started the rescript-deno project because it doesn’t make sense to get full bindings to NodeJS.

The Fetch interface has the ability to implement web servers, and platforms like Deno and Cloudflare Workers already support it.

I haven’t moved the HTTP server part yet, but collaborating with rescript-webapi will make it a more realistic option.

5 Likes