Hello!
I’ve been evaluating Redwood for a product my company is scoping.
I have a few other posts in the forums right now because of my eval, sorry for the spam. Before posting this I read the pre-render docs, searched the forums, searched github, and watched the youtube demo introducing prerender so I’m pretty confident this issue hasn’t been covered yet.
One of our requirements is to have performant logged out SEO-friendly pages. I’m aware SSR isn’t quite here yet, but the Prerender looked quite promising from the docs so I’ve been testing it out to see how it works.
My problem is: I can’t tell if it’s working from a user PoV.
I’ve mostly been testing cells as the content needs to be dynamically generated from db content but doesn’t change much after. To test this I made a little blogging app similar to the tutorial and added a single post to pre-render.
Here’s what I tried:
- Deployed on vercel with neon.tech db. Observed that the
Posts
cells still went into a loading state and did not serve content until after the database finished. I assumed perhaps the slowness was something to do with some serverless cold-start problem and decided to try serverful. - Tried flightcontrol and render.com deploys. Was unable to get flightcontrol working yet but did succeed in getting Render working. I’d say I did see a slight speedup on pre-rendered pages from the network tab — especially in the worst case cold-start POV.
Unfortunately, I still see the same cell behavior. The cells go into a loading state before showing anything and it’s noticable even on quite fast internet. This is fine for a logged-in kind of experience but doesn’t work for my logged-out experiences, and is just perplexing.
yarn rw prerender --dry run
works locally and the build logs in prod reflect it’s happening on deploy too, so I do see a difference at build time, but after I really can’t tell any difference between a pre-rendered page or not.
The network logs and SEO reflect this. Here are the Network logs and lighthouse scores on Render serverful with heavy throttling and cache disabled.
With:
Without Prerender:
Serverless vercel for reference (network tab reflects worst-case cold start situation with neon.tech — it can get really bad in certain cases like this).
So, theres some benefits to the total blocking time perhaps, and the overall load times for lighthouse are definitely being dragged by my unoptimized images. But I would have expected to see some difference in the network waterfalls, and the biggest thing — I don’t understand why cells enter a loading state before rendering when I see it being pre-rendered as html at build time.
Here are my routes:
<Set wrap={MarketingLayout} useAuth={useAuth} prerender>
<Route path="/" page={BlankHomePage} name="home" />
<Route notfound page={NotFoundPage} />
<Route path="/posts/{id}" page={PostPostPage} name="post" />
<Route path="/posts" page={PostPostsPage} name="posts" />
</Set>
Here are my routehooks:
// web/src/pages/Post/PostPage.routeHooks.js
import { db } from '$api/src/lib/db'
export async function routeParameters() {
const posts = await db.post.findMany()
return posts.map((post) => ({ id: post.id }))
}
// web/src/pages/Post/PostsPage.routeHooks.js
import { db } from '$api/src/lib/db'
export async function routeParameters() {
const posts = await db.post.findMany()
return posts.map((post) => ({ id: post.id }))
}
I have two hypotheses:
- I’m misunderstanding how auth interacts with pre-render and missed something in the docs. I have inline ‘edit’ buttons on the posts that appear to authed users and perhaps this is causing the slowdowns?
- I’m misunderstanding how pre-render works altogether and it just doesn’t do what I expected it to do in cells.
I have the rest of the afternoon off, but welcome any and all thoughts on this and will respond when I return. Overall I think I’m bullish on Redwood if I can figure this out. In particular having the Graphql endpoint management seemed to be natural and useful as I need to interact with multiple clients.
Thanks for reading.