Backend for react-three

I found that React-three-fiber is the best way to build the frontend of the three.js webapp.
I am confused what backend will be best suited for it.

  1. What API server side language should I use : Django or PHP or Node js(If node.js express.js or sails.js) ?

  2. Which database would be the best to work with ?

Is MERN Stack the best option to go with…

Backend usually depends on what your application does - not what the frontend is built with.

  • If you know JS/ES very well, your app is very dynamic and requires live connection with the server - go with node or python (express or any of it’s derivatives should do the trick.) Mind that servers get relatively expensive if you underuse them.
  • If you know JS/ES very well, your app is dynamic but not constantly connected to the server, and you want to save some money - go with serverless + node (it does not require using express, it’s just pure node + libraries of your choice.) Mind that serverless gets relatively expensive if you overuse it.
  • If you want static server-side rendering - go with gatsby and simple webhosting.
  • If you want dynamic server-side rendering - go with PHP, if your server supports it.

As for databases - probably an unpopular opinion, but based on experiences I’d advise not to use DBs to store three-related JSONs. It’s very time- and resource-consuming to search these JSONs, plus DBs can have size limits on records’ length.
If you want to store scenes / worlds on servers, use a mix of file storage + searchable database with IDs and tags - ex. DynamoDB + S3 on AWS.

Depends on the app - it’s can also be an overkill if all you’d need from an API is a few endpoints + a simple database.

3 Likes

I am planning to build something where user can login create their own model and save it retrive it later.

Need to store the created models over to the servers

And I need a completely dynamic site , will express handle it seamlessly with aws.
And could you please suggest some reference to store the three js models as you said in dynamoDB or Mongo or anything else

Sounds like you don’t need a server at all - since it’s all stateless, except for the models. Or are these models uploaded live? After every update on the frontend, you instantly sync the model with the database?

If it’s only a “Click here to Save the model” situation, you can for example go with:

  • serverless (AWS Lambda / GC Functions): create 4 endpoints. One will allow the user to log in, second will authenticate existing user, third will allow to upload the models, last to allow reading uploaded models (after authentication.)
  • DynamoDB (GC BigTable / Firestone): 2 tables to store users and model IDs. When user creates an account put their data in one table. When a model is uploaded, put its ID and author ID in the other table (that’s a bit simplified and probably not the safest, later you can add access control to the files and combine it with something like Cognito.)
  • S3 (GC Storage): 1 bucket. When user uploads a model via serverless, create a subfolder for the user in the main bucket and put the model there, save only the ID to the database.

Tbh, it’d be exactly the same story when using express + MERN, just the names of the services change, plus MERN you have to host and backup yourself.

2 Likes

Thankyou so much for your help
Much kowledge will check out everything and try the best one.

Can you reference me somewhere where i can know completely about the backend mainly servers and hosting as I am a frontend postition and new to these stuff , that would be really helpful. Just wanted to know about the different types of servers.

This guide seems to explain a lot of it, and also at once. Though I wouldn’t read all of it - it seems to also have a lot of bloat like Setting up Bootstrap or Add app favicons :’) Could be a good starting point, but read only the parts you’d feel are important and useful for your case.

1 Like
  1. You can start with rather non expensive Cloud hosting for few EU per month - https://www.hetzner.com/cloud - and install in clean Ubuntu everything you need for development nad production.
  2. It’s probably unpopular opinion by SQlite with Python (Flask) can do the job. SQlite does not require server (serverless) - it’s technically a file you can easily transfer from the server to your mobile hardware so you can reuse the same across IOT
    https://www.sqlite.org/whentouse.html
2 Likes

Thankyou so much for taking time and helping me out . Much appreciated .

Thank you somuch will check them out .

have you tried firebase or similar solutions. you can host your app as a static spa, it can still be connected to backend services, databases, etc, without you having to create all that yourself.

I took a dive on knowing more about firebase as you suggested .
Will it be completely reliable to use firebase only or should I set express as the server and then host it in firebase.
Basic requirements my project would need are

  1. Authentication
  2. Storing base models
  3. Storing models created by specific users
  4. Reusing the models

And it is recommended that creating own backend for long term use
I am confused in what way to go .

None of this stuff warrants your own stack imo. I would go for a self baked back end on node when I have my own node services, but just for authentication and storage, I would prefer firebase or competitors. They allow you to make a static site and they have ready made integrations.

1 Like

My two votes are for either serverless architecture as recommended or (if you don’t actually need a website and mostly want the save assets functionality) going with electron + express as a native app

2 Likes