Next Steps for Static Export Migration
1. Complete API Route Migration
We’ve already migrated the following API routes to Firebase Functions:
/api/send-email→ Using the Firebase Function/api/export-data→ Using the Firebase Function/api/auth-status→ Using the Firebase Function
Additional API routes that need to be migrated:
/api/auth/refresh-token/api/verify-token/api/users/api/users/reset-password
2. Client Component Conversion
Convert server components to client components:
- Add
'use client'directive to the top of components that need client-side data fetching - Update data fetching logic to use client-side approach with the new API endpoints
- Ensure proper loading states and error handling for client-side fetching
3. Dynamic Route Handling
For dynamic routes like /tickets/[id]:
Option 1: Use Client-Side Routing
- Update the component to fetch data client-side using ticket ID from params
- Use client component with React Router-style navigation
Option 2: Implement Static Generation for Known Routes
If you have a fixed set of tickets that should be pre-rendered:
// app/(app)/tickets/[id]/page.tsxexport async function generateStaticParams() { // Get list of ticket IDs to pre-render const ticketIds = ["ticket1", "ticket2", ...];
return ticketIds.map(id => ({ id: id, }));}4. Authentication Flow Updates
- Update authentication flow to use the Firebase Auth directly in the client
- Store authentication tokens in a secure way (HTTP-only cookies where possible)
- Update the middleware.ts for static site compatibility
5. Configuration for Static Export
Update Next.js configuration for static export:
module.exports = { output: 'export', images: { unoptimized: true, }, // ... other config}6. Testing
- Test all functionality in a local environment first
- Verify all API calls are correctly routing to Firebase Functions
- Test authentication flow
- Test dynamic routes and navigation
- Verify file uploads and downloads
7. Deployment
-
Build the static site:
Terminal window npm run build -
Deploy Firebase Functions:
Terminal window firebase deploy --only functions -
Deploy the static site to Firebase Hosting:
Terminal window firebase deploy --only hosting
8. Monitoring and Optimization
- Set up proper monitoring for the Firebase Functions
- Optimize static assets and caching
- Implement analytics to track user behavior
- Monitor API usage and costs