Should I make a separate REST api or use my Next project as the api backend
I built a dashboard to allow admins to add products and view orders. What I want to do now is to create a separate project, an e-commerce website for, say stationaries. I want this project to simply call an api for all the backend work. I don't know if I should build the api in the Nextjs project where I did the dashboard or create a separate REST or graphql project. I'm leaning more towards separating it but I want to hear more opinions before I commit to something thanks
3 Replies
okay to be more specific it's kinda like I'm trying to make shopify but we way lesser features
so it's not just going to be one ecommerce site but multiple
the admin is on one site that every shop owner can connect to but they'd have their own separate custom made ecommerce site that'd call an api for things like placing an order
no sorry that's not it
I have an admin nextjs app similar to what shopify is like
I want to offer it as a saas platform
so other developers could make ecommerce websites without worrying about the backend end infrastructure
what I've built is the saas platform and the api's I've made are for the admin user to manage their products. This is all in one next project
Now I want to make the api that is called by the store. should I make it a separate thing - like an express project - or just make more endpoints in the one next project
If your project is API only I would definitely go with something like fastify. Next is built for serving react based Web apps, so if you're only using a backend your throwing away a ton of the overhead that comes with next. Plus your not going to want to deal with all their bullshit on how they handle headers and cookies and shit
If you need to do a lot of blocking work, you may even be better off using a whole different language, but that's a different story. For starting out TS should be fine
Your biggest problem is going to be how to properly network then together but it shouldn't be terrible at the end of the day and you'll learn a lot from the exercise
Okay if I do go with fastify for the API should I use something else - like astro - to build the ecommerce store - not the admin - 'cause I feel like it would be a waste to use an entire Nextjs project for an ecommerce store that isn't handling it's own backend
also on the part where you said "Plus you're not going to want to deal with all their bullshit on how they handle headers" are you talking about Nextjs. Could you elaborate on this? Thank you
that would make it 3 nextjs projects 😢