All serverside next.js
Unanswered
Wuchang bream posted this in #help-forum
Wuchang breamOP
Who knows how to do every component perfectly server side and only small part of it client side? Including loading etc and to minimize the bundle
import "server-only"; means that nothing from the class will be exported/visible to the client?
BTW I think ISR still slows down my loading, even though it should be done in the background
import "server-only"; means that nothing from the class will be exported/visible to the client?
BTW I think ISR still slows down my loading, even though it should be done in the background
49 Replies
Dutch
dont need to do anything, every page is static as default and SSR
server only for logic belongs to server, not ui
@Dutch dont need to do anything, every page is static as default and SSR
Wuchang breamOP
what you mean? 

i have some client components and i see that revalidation still lags the loading, but fresh data is after another refresh or the one after data is fully loaded
Dutch
what that means
@Dutch what that means
Wuchang breamOP
revalidation doesnt fully work in the background
Dutch
and
Wuchang breamOP
its not good
Dutch
why
Wuchang breamOP
because thats the point of ISR to have instant page loaded
Dutch
no
Wuchang breamOP
how no
Dutch
what you think that ISR means
Wuchang breamOP
loading in the background with instant page view with latest loaded data
Dutch
no
Wuchang breamOP
All requests made to these pages (e.g. /blog/1) are cached and instantaneous
Dutch
it says requests, not whole page
and there is no line says that
@Dutch it says requests, not whole page
Wuchang breamOP
request to that page
Dutch
Here's how this example works:
- During next build, all known blog posts are generated (there are 25 in this example)
- All requests made to these pages (e.g. /blog/1) are cached and instantaneous
- After 60 seconds has passed, the next request will still show the cached (stale) page
- The cache is invalidated and a new version of the page begins generating in the background
- Once generated successfully, Next.js will display and cache the updated page
- If /blog/26 is requested, Next.js will generate and cache this page on-demand
btw its not working in app router, only for pages
@Dutch btw its not working in app router, only for pages
Wuchang breamOP
whats not working isr?
Dutch
yea, that docs for pages router
Wuchang breamOP
not possible, you have specifically 'revalidate' export and in pages you have static/server props
same thing
All requests made to these pages (e.g. /blog/1) are cached and instantaneous
Dutch
no not that link, its for pages
Wuchang breamOP
its not xd
Dutch
if you want revalidate cache, you need to call that function in actions
Wuchang breamOP
yes, but you can use 'revalidate = 10' and it will revalidate after 10 seconds
but the first load after 10 seconds is not instant and its slowed
Dutch
export async function generateStaticParams() { // PAGES ROUTER
const posts: Post[] = await fetch('https://api.vercel.app/blog').then((res) =>
res.json()
)
return posts.map((post) => ({
id: String(post.id),
}))
we re not writing it nowadays
Wuchang breamOP
yes, dont know the reason they put that in the /app docs
Dutch
'use server'
import { revalidatePath } from 'next/cache'
export async function createPost() {
// Invalidate the /posts route in the cache
revalidatePath('/posts')
}
<form action={createPost} ...
the way to go
Wuchang breamOP
thats how you can revalidate manually
thats automatic
but im saying that ISR loading is not instant/fully in the background
and import "server-only"; means that nothing from the class will be exported/visible to the client?
Dutch
then its related with your code
Wuchang breamOP
how?
Dutch
need to see it
@Dutch need to see it
Wuchang breamOP
i dmed you
Wuchang breamOP
I also see that all server actions are public, despite the fact that they are not in client components?