#Server component rendering behavior

1 messages · Page 1 of 1 (latest)

lime eagle
#

I need help on displaying loading status on server component.

So let's say I have page.tsx and the url for this page is example.com/ab.
If I add or change the searchParams, like example.com/ab?q=1, then I can see one api call to the server and its response is the difference.

What do we call this behavior in Next.js term?
and how to display loading status next to specific element of the page?

gloomy patioBOT
#

Hi @lime eagle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The behavior you're describing is part of Next.js's server-side rendering capabilities, specifically the use of Server Components. Server Components in Next.js allow you to write UI that can be rendered and optionally cached on the server. The rendering work is split by route segments to enable streaming and partial rendering. This means that when you change the search parameters, Next.js only needs to fetch and render the differences, which can improve performance and user experience ^1^.

To display a loading status next to a specific element of the page, you can use the loading.js file convention or a Suspense component. The loading.js file provides a way to show a loading state for a whole route or route-segment, while the Suspense component allows you to display a fallback until components nested within it have finished loading ^2^.

Here's an example of how you might use the Suspense component to show a loading state for a specific part of your UI:

import { Suspense } from 'react';
import { PostFeed, Weather } from './components';
 
export default function Posts() {
 return (
 <section>
 <Suspense fallback={<p>Loading feed...</p>}>
 <PostFeed />
 </Suspense>
 <Suspense fallback={<p>Loading weather...</p>}>
 <Weather />
 </Suspense>
 </section>
 );
}

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@lime eagle kapa.ai is still learning and improving, please let us know how it did by reacting below

lime eagle
#

my page.tsx file doesn't look like that.
I have pure html elements on the page.tsx.

#

my page.tsx file doesn't look like that.
I have pure html elements on the page.tsx.

#

@gloomy patio

gloomy patioBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Sorry @lime eagle, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

lime eagle
#

my page.tsx file doesn't look like that.
I have pure html elements on the page.tsx.

#

@gloomy patio

gloomy patioBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Sorry @lime eagle, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

lime eagle
#

@gloomy patio

gloomy patioBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Sorry @lime eagle, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

lime eagle
#

when searchparams change, how to get loading status in Server component? need to shwo loading status next to the specific element of the current page.

#

@gloomy patio

gloomy patioBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Sorry @lime eagle, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

lime eagle
#

@gloomy patio

gloomy patioBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Sorry @lime eagle, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

twin coyote
#

How to get the calendar events using Google authentication with NextAuth in nextjs app router

lime eagle
#

this is where I've created in.