Skip to content

No Vendor Lock-In in NuxSaaS

Introduction

NuxSaaS is designed with a strong focus on avoiding vendor lock-in. This means you can deploy, migrate, and operate your SaaS application across different cloud providers and environments without being tied to a single vendor’s proprietary services or APIs. This document explains how NuxSaaS achieves this, and why it matters for your project’s flexibility and longevity.

How NuxSaaS Avoids Vendor Lock-In

1. Environment-Driven Configuration

  • All critical service endpoints (database, cache, email, etc.) are configured via environment variables, not hardcoded values.
  • See .env.example for a full list of configurable variables:
    • NUXT_NITRO_PRESET to switch between Node.js server and Cloudflare Workers
    • NUXT_CF_HYPERDRIVE_ID for the database connection string, required when using Cloudflare Workers
    • NUXT_DATABASE_URL for the database connection string, required when using Node.js server
    • NUXT_REDIS_URL for the cache backend, required when using Node.js server

This approach allows you to swap out infrastructure components (e.g., move from Local Postgres to Serverless Postgres, or from Redis to another cache) by simply changing environment variables, with no code changes required.

2. Pluggable Database and Cache Drivers

  • The file server/utils/drivers.ts abstracts database and cache access.
  • For the database, it uses a standard PostgreSQL driver (pg), and the connection string is dynamically selected based on the runtime environment (Node.js server or Cloudflare Hyperdrive).
  • For caching, it uses either Redis (via ioredis) or a key-value store abstraction (hubKV) depending on the deployment preset.

Key code snippet:

ts
const getDatabaseUrl = () => {
  if (runtimeConfig.preset == 'node-server') {
    return runtimeConfig.databaseUrl
  } else {
    return hyperdrive?.connectionString || runtimeConfig.databaseUrl
  }
}

This means you can run NuxSaaS on your own server, or on Cloudflare Worker, without rewriting your data access logic.

Why No Vendor Lock-In Matters

  • Portability: You can deploy NuxSaaS on any cloud provider, on-premises, or even locally for development and testing.
  • Cost Control: Easily migrate to a different provider if pricing or service quality changes.
  • Future-Proofing: Avoid being forced to rewrite large parts of your codebase if a vendor discontinues a service or changes their API.
  • Compliance: Meet data residency or regulatory requirements by choosing where and how your data is stored and processed.
  • Community and Ecosystem: By relying on open standards and popular libraries, you benefit from community support and avoid being dependent on a single vendor’s roadmap.