82 | Note: This demo simulates a slow database or backend connection to 83 | demonstrate streaming. 84 |
85 | > 86 | ); 87 | } 88 | -------------------------------------------------------------------------------- /app/components/footer.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export function Footer({ children }: React.PropsWithChildren<{}>) { 4 | return ( 5 | 56 | ); 57 | } 58 | -------------------------------------------------------------------------------- /app/routes/node.tsx: -------------------------------------------------------------------------------- 1 | import type { LoaderArgs } from '@vercel/remix'; 2 | import { useLoaderData } from '@remix-run/react'; 3 | 4 | import { Footer } from '~/components/footer'; 5 | import { Region } from '~/components/region'; 6 | import { Illustration } from '~/components/illustration'; 7 | 8 | let isCold = true; 9 | let initialDate = Date.now(); 10 | 11 | export async function loader({ request }: LoaderArgs) { 12 | const wasCold = isCold; 13 | isCold = false; 14 | 15 | // `process.versions.node` only exists in the Node.js runtime, naturally 16 | const version = process.versions.node; 17 | 18 | const region = process.env.VERCEL_REGION; 19 | if (!region) { 20 | throw new Error('`VERCEL_REGION` is not defined'); 21 | } 22 | 23 | return { 24 | isCold: wasCold, 25 | region, 26 | version, 27 | date: new Date().toISOString(), 28 | }; 29 | } 30 | 31 | export function headers() { 32 | return { 33 | 'x-serverless-age': Date.now() - initialDate, 34 | }; 35 | } 36 | 37 | export default function App() { 38 | const { version, region, isCold, date } = useLoaderData