SpaceyaTech / SYT-Web-Redesign

https://www.spaceyatech.com/
Apache License 2.0
8 stars 25 forks source link

SEO: Add `Suspense` to page components in routes #172

Closed sonylomo closed 3 months ago

sonylomo commented 4 months ago

Description

We're improving the SEO performance of the website. Having a fallback Loader component for every page before it loads helps bump up SEO.

You could do some further reading here:

Tasks

// src/router/index.jsx
import {Suspense} from 'react';

const router = createBrowserRouter([
  {
    path: "/",
    element: 
     <Suspense fallback={<div>Loading...</div>}>
        <Layout />
     </Suspense>,
    children: [
      {
        path: "/",
        element: 
         <Suspense fallback={<div>Loading...</div>}>
            <LandingPage />
         </Suspense>,,
      },
      {
        path: "/products",
        element: 
         <Suspense fallback={<div>Loading...</div>}>
            <Products />
         </Suspense>,
      },
... rest of code
sonylomo commented 4 months ago

Feel free to reach out if you have any inquiries or need more guidance.