// pages/stuff/[id].js import { useRouter } from 'next/router'; import Link from 'next/link'; import useSWR from 'swr' export default function Page() { const router = useRouter(); const id = router.query.id if (id == null) { // Static pre-generated HTML return

Loading...

} return ( <>

Page for {id}


) } const fetcher = (...args) => fetch(...args).then((res) => res.json()) function Content({ id }) { const { data, error } = useSWR('https://jsonplaceholder.typicode.com/todos/' + id, fetcher) if (error) return

Failed to load

if (!data) return

Loading...

return (
{JSON.stringify(data, null, 2)}
); }