Explore Prerendering in Blazor Server & WebAssembly with .NET 8 🔥


Hey Reader,

In this week's newsletter, I'm focusing on a fundamental yet often misunderstood aspect of Blazor in .NET 8 - prerendering in the new render modes (Server, WebAssembly, and Auto).

🚀 Prerendering Issue Resolution Video

You have two choices: watch the video below, which illustrates the common issue with prerendering, or continue reading for the code details.

video preview

🌟 Disabling Prerendering in Blazor with .NET 8

It's quite straightforward. When you opt for one of Blazor's new rendering modes in .NET 8 - Server, WebAssembly, or Auto - you'll need to use the @rendermode directive. This directive allows you to select one of these modes for either a page or a component:

Here's an important note: if you're loading data, for example, prerendering is on by default. This can cause an unsightly flicker. Observe in the gif below how the values change twice upon page reload.

That's prerendering for you. While it might be beneficial for SEO, there are times when it's not desirable due to the negative impact on user experience.

To address this, simply instantiate the render mode of your choice and set the prerender parameter to false.

This solution is applicable to all render modes and is also useful if you're looking to modify the effect for specific components rather than an entire page.


💌 Now It's Your Turn! How do you feel about prerendering? When and where would you use it?

A huge thank you to our community, and special gratitude to my Patrons for their steadfast support. Your contributions are vital to the success of this newsletter and my YouTube channel.

Excited for our next coding journey together. Stay safe and happy coding! 💻

Take care,

Patrick


Patrick God

Become a .NET & Blazor expert with weekly tutorials featuring best practices and the latest improvements, right in your inbox.

Read more from Patrick God

Hey friend, I realized something recently: AI was slowing me down. I’d send a prompt… and wait. Even though I already knew what to do next. So I changed one thing. I stopped using AI like a tool and started using it like a team. Multiple chats. Multiple tasks. All running at once. Watch it below 👇 Happy prompting! Take care,Patrick P.S. If you want help setting this up for your workflow or your team, click here.

Hey friend, Blazor Server or WebAssembly? Lately, I had a call with a student migrating a desktop app… and this question came up immediately. So I made a quick video to break it down: You'll learn: When Blazor Server is the simplest choice When you actually need WebAssembly And when an API becomes necessary Enjoy! Take care,Patrick P.S. Our next live office hours inside the .NET Web Academy start tomorrow. Join here.

video preview

Hey friend, Working from home as a .NET developer sounds great. Freedom. No meetings. Full control. But after a while, it gets heavy. You make every decision alone. Architecture. Azure. Refactoring. Deployment. And sometimes you just want someone to say, “Yeah, that’s fine. Ship it.” AI helps. Tutorials help. But real conversations with other developers hit different. In today's video, I talk about why working alone can slow us down and why feedback from other devs matters more than we think....