Home  >  Q&A  >  body text

Nextjs: loading or suspense fallback doesn't show up in production

I have migrated my personal pages to the application directory using nextjs v13.

I tried first adding the RSC loader in the fallback attribute of the Suspense component and adding the # in the path of each route located in the app directory ##loading Components.

// src/app/posts/loading.tsx
import { Container } from '~/components/organisms/container';

export default function Loading() {
  return (
    <Container>
      {/* Add a big loading string with tailind */}
      <span className="text-6xl font-bold text-center text-red-500">Loading...</span>
    </Container>
  );
}

There is also this

// src/app/posts/page.tsx
export default async function PostsPage() {
  return (
    <Container>
      <PageHeader
        title='Posts'
        description="I love to write about things I'm learning. 
            Blogging is a great way to improve and share knowledge.
            And who knows, maybe one day it might help me to write a book!"
      />
      <Suspense
        fallback={
          <Container>
            {/* Add a big loading string with tailind */}
            <span className='text-6xl font-bold text-center text-red-500'>
              Loading...
            </span>
          </Container>
        }
      >
        {/* @ts-expect-error Server Component */}
        <Posts />
      </Suspense>
    </Container>
  );
}

Both are committed to local development

But they don't show up in my vercel deployment

I am using node

18.16 locally and node 18.x in my vercel deployment. I also deployed the nextjs project in vercel using default configuration.

If anyone needs more details, the branch code can be found here

P粉685757239P粉685757239228 days ago379

reply all(1)I'll reply

  • P粉937769356

    P粉9377693562024-03-28 09:20:33

    You didn't include how to load the data, but if you use the new fetch then it may be related to the built-in caching nextjs is doing -- it will cache the data indefinitely by default Down. In production, your post will look like it loaded immediately

    reply
    0
  • Cancelreply