Oblien Docs

Deployment Best Practices

Follow these best practices to ensure smooth, efficient deployments on Oblien.

Before Deploying

1. Test Your Build Locally

Always verify your build works locally before deploying:

npm run build
npm start

This helps catch build errors early and reduces deployment failures.

2. Clean Your Dependencies

Ensure your package.json is accurate:

# Remove unused dependencies
npm prune

# Update lockfile
npm install

Missing dependencies are the #1 cause of deployment failures!

3. Use Environment-Specific Configuration

Don't hardcode values that change between development and production:

// Bad
const API_URL = 'http://localhost:3001';

// Good
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001';

4. Check Node.js Version

Verify your app works with the Node.js version Oblien uses:

{
  "engines": {
    "node": ">=18.0.0"
  }
}

During Configuration

1. Use Standard npm Scripts

Stick to conventional script names in package.json:

{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  }
}

2. Optimize Build Commands

For faster builds, use production optimizations:

# Next.js with optimizations
NODE_ENV=production npm run build

# React with production build
npm run build --production

3. Specify the Correct Output Directory

Double-check your framework's output directory:

  • Next.js (server): .next
  • Next.js (static): out
  • Create React App: build
  • Vite: dist
  • SvelteKit: build

4. Configure Root Directory for Monorepos

If using a monorepo, set the root directory:

./apps/web
./packages/frontend

After Deploying

1. Monitor Build Logs

Always review your build logs:

  • Check for warnings or deprecation notices
  • Verify all dependencies installed successfully
  • Confirm the build completed without errors

2. Test Your Deployment

After deployment:

  • Visit your live URL
  • Test critical user paths
  • Check browser console for errors
  • Verify API connections work

3. Enable Auto-Deploy

For continuous delivery:

  1. Enable GitHub webhook integration
  2. Every push to your main branch auto-deploys
  3. Get instant feedback on changes

Auto-deploy helps catch issues immediately and keeps your app always up-to-date.

4. Monitor Performance

Keep an eye on:

  • Build times (should stay consistent)
  • Application startup time
  • First load performance

Common Pitfalls to Avoid

Don't Commit node_modules

Always add to .gitignore:

node_modules/
.next/
dist/
build/

Don't Use Development Mode

Ensure production builds:

# In package.json
"build": "NODE_ENV=production next build"

Don't Ignore Warnings

Build warnings often indicate:

  • Missing dependencies
  • Deprecated packages
  • Potential runtime errors

Don't Skip Testing

Always test before deploying:

  • Run tests locally
  • Check all environment variables
  • Verify external API connections

Performance Optimization

1. Reduce Bundle Size

# Analyze your bundle
npm run build -- --analyze

# Remove unused dependencies
npm uninstall unused-package

2. Use Production Dependencies Only

Separate dev and production dependencies:

{
  "dependencies": {
    "react": "^18.0.0"  // Production
  },
  "devDependencies": {
    "eslint": "^8.0.0"  // Development only
  }
}

3. Optimize Images and Assets

  • Compress images before committing
  • Use next/image for Next.js apps
  • Lazy load non-critical assets

4. Enable Caching

Most frameworks have built-in caching:

// Next.js caching
export const revalidate = 3600; // 1 hour

Security Best Practices

1. Never Commit Secrets

Use environment variables for:

  • API keys
  • Database credentials
  • OAuth secrets
  • Private tokens

2. Review Dependencies

Check for vulnerabilities:

npm audit
npm audit fix

3. Keep Dependencies Updated

Regularly update to get security patches:

npm update
npm outdated

Deployment Checklist

Before every deployment:

  • Build works locally
  • All tests pass
  • Dependencies are up to date
  • No hardcoded secrets or URLs
  • Correct framework and settings selected
  • Output directory is correct
  • Environment variables configured
  • .gitignore includes build artifacts

Getting Help

If you encounter issues:

  1. Check build logs for error messages
  2. Review Troubleshooting Guide
  3. Verify configuration settings
  4. Test the exact build command locally
  5. Contact support with deployment ID and logs

Next Steps