feat(web): enable prerender for static pages to improve TTFB#2048
feat(web): enable prerender for static pages to improve TTFB#2048
Conversation
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
✅ Deploy Preview for hyprnote-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughEnabled prerendering and expanded prerender filter in the Vite TanStack Start config; added CI-driven Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
🔇 Additional comments (1)
Comment |
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/vite.config.ts (1)
24-32: New filter entries for/,/pricing,/enterprise– semantics and optional tidy‑upAdding
path === "/",path.startsWith("/pricing"), andpath === "/enterprise"matches the described prerender targets. A couple of optional considerations:
- If there’s any chance of other top‑level routes beginning with
/pricingor/productthat shouldn’t be static, consider using exact+subpath checks instead of rawstartsWith, e.g.path === "/pricing" || path.startsWith("/pricing/").- For maintainability, you could factor this into a small helper/array of prefixes to avoid a long chain of
||, but that’s style‑only and not required for correctness.Functionally this filter looks fine as written; the main thing is confirming the matched routes are indeed safe to prerender.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/vite.config.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.ts: Agent implementations should use TypeScript and follow the established architectural patterns defined in the agent framework
Agent communication should use defined message protocols and interfaces
Files:
apps/web/vite.config.ts
**/*.config.{ts,json}
📄 CodeRabbit inference engine (CLAUDE.md)
Agent configuration should be centralized and externalized from implementation logic
Files:
apps/web/vite.config.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Avoid creating a bunch of types/interfaces if they are not shared. Especially for function props, just inline them instead.
Never do manual state management for form/mutation. Use useForm (from tanstack-form) and useQuery/useMutation (from tanstack-query) instead for 99% of cases. Avoid patterns like setError.
If there are many classNames with conditional logic, usecn(import from@hypr/utils). It is similar toclsx. Always pass an array and split by logical grouping.
Usemotion/reactinstead offramer-motion.
Files:
apps/web/vite.config.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Redirect rules - hyprnote-storybook
- GitHub Check: Redirect rules - hyprnote
- GitHub Check: Header rules - hyprnote-storybook
- GitHub Check: Header rules - hyprnote
- GitHub Check: Pages changed - hyprnote-storybook
- GitHub Check: Pages changed - hyprnote
- GitHub Check: fmt
- GitHub Check: Devin
🔇 Additional comments (1)
apps/web/vite.config.ts (1)
18-35: Prerender enablement scope looks right; ensure targeted routes are truly staticTurning
prerender.enabledtotruewith thisfilterwill limit prerendering to the marketing/docs/etc paths and keep/app/*SSR-only, which matches the PR intent. The config wiring withtanstackStartand the Netlify plugin looks consistent.Please double‑check for the routes matched by this filter (
/,/blog/*,/docs/*,/changelog/*,/legal/*,/product/*,/pricing*,/enterprise) that:
- Their loaders/actions don’t depend on per‑request auth/session or cookies.
- They don’t assume browser globals at module/loader time (e.g.,
window,document) without atypeof window !== "undefined"guard.- Build time and Netlify function usage remain acceptable after prerendering is enabled.
If all of that holds, the change looks good to ship.
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Summary
Enables prerendering for static marketing/docs/blog pages to improve TTFB (Time To First Byte). Currently all requests go through Netlify Functions for SSR, causing cold start latency (400-900ms+ TTFB). With prerender enabled, static pages will be served directly from CDN.
Changes:
prerender.enabledtotruein TanStack Start config/) to the prerender filter/enterpriseto the prerender filterskipValidationfor env vars in CI to allow prerender to complete without server secretsPages that will be prerendered:
/,/blog/*,/docs/*,/changelog/*,/legal/*,/product/*,/pricing,/enterprisePages that remain SSR (for auth):
/app/*Review & Testing Checklist for Human
/app/*routes still work - these should still use SSR and require authenticationRecommended test plan:
/,/docs/quickstart,/blog,/changelog,/pricing,/enterpriseNotes
Prerender was previously enabled in commit 81993cd and disabled 2 hours later in 4da9398. The likely cause was the global
fetchUser()call in__root.tsxwhich was removed in PR #1939, so prerender should work now.The
skipValidationflag inenv.tsonly applies whenCI=true(GitHub Actions). Netlify production/preview builds will still validate env vars at runtime, ensuring misconfigurations are caught in real deployments.Link to Devin run: https://app.devin.ai/sessions/66411affa67940a78f1f796856710095
Requested by: yujonglee (@yujonglee)