| 1 | # Runtime Selection |
| 2 | |
| 3 | ## Use Node.js Runtime by Default |
| 4 | |
| 5 | Use the default Node.js runtime for new routes and pages. Only use Edge runtime if the project already uses it or there's a specific requirement. |
| 6 | |
| 7 | ```tsx |
| 8 | // Good: Default - no runtime config needed (uses Node.js) |
| 9 | export default function Page |
| 10 | |
| 11 | // Caution: Only if already used in project or specifically required |
| 12 | export const runtime = |
| 13 | ``` |
| 14 | |
| 15 | ## When to Use Each |
| 16 | |
| 17 | ### Node.js Runtime (Default) |
| 18 | |
| 19 | - Full Node.js API support |
| 20 | - File system access (`fs`) |
| 21 | - Full `crypto` support |
| 22 | - Database connections |
| 23 | - Most npm packages work |
| 24 | |
| 25 | ### Edge Runtime |
| 26 | |
| 27 | - Only for specific edge-location latency requirements |
| 28 | - Limited API (no `fs`, limited `crypto`) |
| 29 | - Smaller cold start |
| 30 | - Geographic distribution needs |
| 31 | |
| 32 | ## Detection |
| 33 | |
| 34 | **Before adding `runtime = 'edge' |
| 35 | |
| 36 | 1. Does the project already use Edge runtime? |
| 37 | 2. Is there a specific latency requirement? |
| 38 | 3. Are all dependencies Edge-compatible? |
| 39 | |
| 40 | If unsure, use Node.js runtime. |