Nuxt, backend required?
Hi all,
I’m building a SaaS in Nuxt.
I know this has been mentioned multiple times but I’ve spent the last few nights researching if it’s a good idea to use Nuxt has the backend and the answers are never straight forward.
Is Nuxt (and is it a good idea) okay to use as a backend for a SaaS application, the main backend work will be login/register/auth and database querying for all the dashboard data.
For the actual services I am providing I plan to use something like Django/Go, which will do any work that runs in the background, so essential Nuxt backend will create/fetch data from the database, whilst the third party backend will do the bulk of the of compute intensive work.
How does that sound? or should I use Nuxt as a frontend only and create an api route in the third party backend to handle everything?
Thanks Nuxters!
4 Replies
Hi @nullptr. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, Nuxt can be used as both a frontend and backend for a SaaS application, especially for handling authentication and database operations as you described.
Using Nuxt for Backend Functionality
Nuxt provides server-side capabilities through its server engine called Nitro, which allows you to create API endpoints directly within your Nuxt application:
1. Authentication & Sessions: Nuxt has good support for authentication workflows. You can use modules like
nuxt-auth-utils
to implement login, registration, and session management Sessions and Authentication.
2. API Endpoints: You can create API endpoints in the server/api
directory that can handle database operations and other backend logic.
3. Database Integration: While Nuxt doesn't include database drivers, you can integrate with databases through Nitro or use modules that provide database connectivity.
Your Proposed Architecture
Your approach of using Nuxt for authentication and data fetching while offloading compute-intensive tasks to specialized services (Django/Go) is actually a common and sensible architecture:
1. Nuxt for Frontend + Basic Backend: Handle UI, authentication, and simple CRUD operations.
2. Specialized Services: Use Django/Go for background processing and compute-intensive tasks.
This is a valid microservices-style approach that plays to the strengths of each technology.
Considerations
When deciding whether to use Nuxt as a backend, consider:
1. Team Expertise: If your team is more comfortable with JavaScript/TypeScript, using Nuxt for both frontend and backend can be advantageous.
2. Deployment: Nuxt can be deployed to various environments including serverless platforms, which might simplify your infrastructure Universal Deployment.
3. Performance: For simple CRUD operations and authentication, Nuxt's server capabilities are generally sufficient. For heavy computational tasks, your approach of offloading to specialized services is appropriate.
Alternative Approach
The alternative you mentioned—using Nuxt purely as a frontend and creating all API endpoints in your Django/Go backend—is also valid. This creates a cleaner separation of concerns but requires managing two separate codebases and potentially more complex deployment setups.
For a SaaS application with the requirements you described, either approach can work well. Your proposed hybrid approach seems well-balanced, leveraging Nuxt's strengths while recognizing its limitations for compute-intensive operations.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@800662368622739476> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
thanks, yeah it's what I assumed I just read about the nuxt-haters who say it can't and should not be used for backend web application, which seemed a little crazy if its just handling database, payment flows etc
you can also use the BFF (backend for frontend) pattern, which is as mentioned basically using the Nuxt backend as a proxy for your Django/Go backend. Good way to keep sensitive api keys hidden for example