78 | Note: This demo simulates a slow database or backend connection to 79 | demonstrate streaming. 80 |
81 | > 82 | ); 83 | } 84 | -------------------------------------------------------------------------------- /app/node-streaming/page.tsx: -------------------------------------------------------------------------------- 1 | import { Suspense } from 'react'; 2 | import { Footer } from '../components/footer'; 3 | import { Region } from '../components/region'; 4 | import { Illustration } from '../components/illustration'; 5 | 6 | function sleep(ms: number) { 7 | return new Promise((resolve) => setTimeout(() => resolve(''), ms)); 8 | } 9 | 10 | async function Delay({ 11 | children, 12 | ms, 13 | }: { 14 | children: React.ReactNode; 15 | ms: number; 16 | }) { 17 | await sleep(ms); 18 | return children; 19 | } 20 | 21 | export const runtime = 'nodejs'; 22 | export const dynamic = 'force-dynamic'; 23 | 24 | async function getNodeData() { 25 | // `process.versions.node` only exists in the Node.js runtime, naturally 26 | const version: string = process.versions.node; 27 | const region = process.env.VERCEL_REGION; 28 | 29 | return { version, region }; 30 | } 31 | 32 | export default async function Page() { 33 | const { version, region } = await getNodeData(); 34 | const date = new Date().toISOString(); 35 | 36 | return ( 37 | <> 38 |