the-happy-programmer / the-happy-programmer-nextjs

Programming Courses
https://thehappyprogrammer.com/
1 stars 1 forks source link

Add Fallbacks #14

Open MyNameIsBond opened 10 months ago

MyNameIsBond commented 10 months ago

Add Suspense FallBacks for all pages

Example


import { MDXRemote } from 'next-mdx-remote/rsc'

// app/page.js
export default function Home() {
  return (
    // Ideally this loading spinner would ensure there is no layout shift,
    // this is an example for how to provide such a loading spinner.
    // In Next.js you can also use `loading.js` for this.
    <Suspense fallback={<>Loading...</>}>
      <MDXRemote
        source={`# Hello World

        This is from Server Components!
        `}
      />
    </Suspense>
  )
}