For detailed SSR configuration options, see Configuration. This guide focuses on deployment-specific setup.
General requirements
Before deploying your LiveVue application, ensure you have:- Node.js 19+ installed in production
- Standard Phoenix deployment requirements
- Built assets before deployment
Fly.io deployment guide
Here’s a detailed guide for deploying to Fly.io. Similar principles apply to other hosting providers.Generate Dockerfile
First, generate a Phoenix release Dockerfile:Modify Dockerfile
Update the generated Dockerfile to include Node.js. Here are the key sections:Key changes:
- Add
curlto build dependencies - Install Node.js in both build and production stages
- Add npm install step for assets
Launch on Fly.io
Configure database
- Choose “Fly Postgres” for database
- Name your database
- Consider development configuration for cost savings
- Review other settings as needed
Other deployment options
Heroku
For Heroku deployment:Use Phoenix buildpack
Follow the Phoenix Heroku deployment guide
Docker
If using your own Docker setup:- Ensure Node.js 19+ is installed in your production image
- Follow standard Phoenix deployment practices
- Configure SSR for production (see Configuration)
Custom server
For bare metal or VM deployments:Follow Phoenix deployment guide
Follow the standard Phoenix deployment guide
SSR configuration for production
LiveVue uses the NodeJS mode for production SSR. Add this to yourapplication.ex:
lib/my_app/application.ex
pool_size determines how many Node.js processes are maintained in the pool. Adjust based on your needs:
- Low traffic:
pool_size: 2-4 - Medium traffic:
pool_size: 4-8 - High traffic:
pool_size: 8-16
Production checklist
Use this checklist to ensure your LiveVue app is production-ready:- Node.js 19+ installed in production environment
- Assets built using
mix assets.deploy - SSR configured properly with NodeJS supervisor
- Database configured and migrations run
- Environment variables set (SECRET_KEY_BASE, DATABASE_URL, etc.)
- SSL certificates configured (if needed)
- Production secrets generated
- Release configuration tested locally
- Health checks configured
- Monitoring and logging set up
Troubleshooting
SSR not working
Verify Node.js installation
Verify Node.js installation
Check SSR configuration
Check SSR configuration
Ensure your config includes:And verify the NodeJS supervisor is in your application supervision tree.
Verify server bundle exists
Verify server bundle exists
Check that If missing, ensure
priv/static/server.mjs exists in your release:mix assets.deploy runs successfully during build.Asset loading issues
Assets not found (404 errors)
Assets not found (404 errors)
- Verify assets were built during deployment
- Check that
staticdirectory is included in your release - Inspect the digest manifest in
priv/static/cache_manifest.json - Ensure your endpoint configuration includes static assets:
Components not rendering
Components not rendering
- Check browser console for JavaScript errors
- Verify Vue components are included in the client bundle
- Ensure
getHooks()is properly configured in your app.js - Test SSR by checking the initial HTML source
Performance issues
Slow SSR rendering
Slow SSR rendering
Consider adjusting the NodeJS pool size:Monitor your application to find the optimal pool size for your traffic patterns.
High memory usage
High memory usage
- Reduce NodeJS pool size if memory is constrained
- Consider disabling SSR for some components using
v-ssr={false} - Profile your Vue components for memory leaks
- Ensure components are properly unmounted
Build failures
npm install fails during build
npm install fails during build
- Verify Node.js is installed in the build stage
- Check that
package.jsonandpackage-lock.jsonare copied to the build context - Ensure network connectivity in the build environment
- Try running
npm ciinstead ofnpm installfor more reproducible builds
mix assets.deploy fails
mix assets.deploy fails
- Check that all npm dependencies are installed
- Verify Vite configuration is correct
- Look for TypeScript or compilation errors in assets
- Ensure the assets directory exists and is accessible
Performance optimization tips
Enable compression
Ensure Gzip compression is enabled for static assets:config/prod.exs
Use CDN for assets
Consider using a CDN for static assets in high-traffic applications:config/prod.exs
Optimize SSR
- Disable SSR for components that don’t need it using
v-ssr={false} - Use SSR primarily for initial page load and SEO
- Consider caching SSR output for frequently accessed pages
Monitor performance
Set up monitoring to track:- SSR rendering time
- WebSocket message sizes
- Component mount/update times
- Memory usage and garbage collection
Next steps
Configuration
Fine-tune your production configuration
Architecture
Understand how LiveVue works under the hood
Testing
Test your application before deployment
GitHub Discussions
Get help from the community