Static Deployment Notes
Due to the Next.js App Router and dynamic routes like /tickets/[id], we faced challenges using the static export mode (output: 'export').
When using static export mode with dynamic routes, Next.js requires generateStaticParams() to be implemented for each dynamic route to pre-render all possible paths. This works for sites with a fixed set of possible dynamic routes known at build time.
Current Solution
Our current solution uses:
- Firebase Hosting for static files
- Firebase Functions to serve the Next.js application
This provides a simple landing page when users first visit the site, but the actual application functionality is served by a Firebase Function called nextServer.
Alternative Approaches
1. Implement generateStaticParams
If you want to use static export, you can modify the dynamic route pages to implement generateStaticParams(). For example:
// src/app/(app)/tickets/[id]/page.tsxexport async function generateStaticParams() { // This would need to fetch all possible ticket IDs at build time // Not ideal for a dynamic ticketing system where new tickets are created regularly return [ { id: 'placeholder-id-1' }, { id: 'placeholder-id-2' }, // ...etc ];}2. Use Server-Side Rendering with Cloud Run
A better approach for production would be to use Google Cloud Run to host the Next.js application with full server-side rendering support:
- Build the application with
output: 'standalone' - Create a Dockerfile that serves the standalone output
- Deploy to Cloud Run
This would provide full Next.js functionality including dynamic routes and API routes.
3. Use Vercel
Next.js is designed to work best with Vercel, which provides:
- Automatic deployment from Git
- Full support for dynamic routes
- Edge functions for API routes
- Global CDN
Current Limitations
Our current Firebase Functions approach:
- Serves a simple placeholder HTML for all routes
- Does not provide actual Next.js functionality
- Is meant as a temporary solution until a proper deployment strategy is implemented
Next Steps
- For a production deployment, consider migrating to Cloud Run or Vercel
- Alternatively, refactor the application to use static export with client-side data fetching
- Or implement
generateStaticParams()for all dynamic routes if the set of possible values is known at build time