SAYED.DEV
May 20, 20265 min read

Scaling Vue 3 SaaS Applications for Enterprise Operations

Key lessons in folder organization, dynamic route compilation, and state management at scale.

Scaling the Core: Vue 3 in Enterprise SaaS

When scaling B2B SaaS platforms to serve thousands of corporate customers, the typical pitfalls aren't network load—they are codebase maintainability and team friction. A monolithic frontend structure leads to massive merge conflicts, sluggish build times, and high cognitive load. Here are the structural standards we established to scale our Vue 3 codebases:

1. The 3-App Domain Routing Pattern

Rather than shipping distinct codebases or building separate web apps for Super Admins, Client Dashboards, and Public Subdomain portals, we unified them into a 3-in-1 codebase model. Using vite-plugin-pages and standard layout wrappers, the app parses the subdomains dynamically at boot time:
// src/router/guards.ts
router.beforeEach((to, from, next) => {
    const subdomain = getActiveSubdomain(window.location.hostname);
    
    if (subdomain === 'admin' && !to.path.startsWith('/admin')) {
        return next('/admin');
    }
    
    if (isCustomerDashboard(subdomain) && to.path.startsWith('/admin')) {
        return next('/dashboard/unauthorized');
    }
    
    next();
});
This unified code pattern reduced shared utility duplication and ensured that common components (like our custom forms engines and alert banners) were instantly accessible to all modules.

2. Standardizing the Setup API

We strictly enforced the use of Vue 3