#title Weekly Vue News #85 - Rendering Modes In Nuxt #preview Ready for your weekly Vue & Nuxt dose?
Rendering Modes In Nuxt
Hi π
I have a lot of exciting content to share with you today, including a valuable Nuxt tip about rendering modes. Additionally, I've curated a selection of top-notch Vue content that I think you'll find helpful in your web development journey.
In addition to that, I also have a roundup of the latest web development news and tools, to keep you up-to-date with the latest trends in the industry.
I appreciate your support and hope you find this issue informative and helpful.
Have a lovely week βοΈ
To support me:
- π Recommend the newsletter to your friends: it really helps!
- πΈ Sponsor the newsletter
- π§΅ Retweet the latest Twitter thread
- π¨ Reply to this email: feedback is welcome
Nuxt 3 offers three different rendering modes:
- Client-side rendering
- Universal rendering
- Hybrid rendering
Client-Side Rendering
Per default, a Vue.js application is rendered in the browser (or client). Vue.js generates HTML elements after the browser downloads and parses all the JavaScript code containing the instructions to create the current interface.
Read about the
Client-side rendering is a suitable option for web applications with high interactivity, which don't require indexing or are frequently accessed by users. This approach can utilize browser caching to bypass the downloading process on subsequent visits. Examples of such applications include SaaS, back-office applications, and online games.
Universal Rendering
By enabling universal (client-side + server-side) rendering, the server returns a fully rendered HTML page to the browser when the browser requests a URL.
In contrast to client-side rendering, users immediately get the application's content (similar to traditional server-side rendering).
To avoid losing the benefits of client-side rendering, the client loads the JavaScript code on the server in the background once the HTML document has been downloaded. The browser interprets it again, and Vue takes control of the document and enables interactivity. Hence it's called hence Universal rendering.
Universal rendering allows a Nuxt application to provide quick page load times while preserving the benefits of client-side rendering.
Read about the
The versatility of universal rendering allows it to adapt to a wide range of use cases and is particularly well-suited for content-focused websites such as blogs, marketing sites, portfolios, e-commerce sites, and marketplaces.
Hybrid Rendering
Hybrid rendering allows different caching rules per route using route rules and decides how the server should respond to a new request on a given URL.
Route rules are still under active development and subject to change.
Since Release Candidate 12, Nuxt 3 has a public beta for hybrid rendering and route rules.
Route rules allow us to define rules for a group of Nuxt routes, change rendering mode or assign a cache strategy based on a route.
Let's take a look at an examplary configuration:
1 export default defineNuxtConfig({
2 routeRules: {
3 // Static page generated on-demand, revalidates in background
4 '/blog/**': { swr: true },
5 // Static page generated on-demand once
6 '/articles/**': { static: true },
7 // Set custom headers matching paths
8 '/_nuxt/**': { headers: { 'cache-control': 's-maxage=0' } },
9 // Render these routes with SPA
10 '/admin/**': { ssr: false },
11 // Add cors headers
12 '/api/v1/**': { cors: true },
13 // Add redirect headers
14 '/old-page': { redirect: '/new-page' },
15 '/old-page2': { redirect: { to: '/new-page', statusCode: 302 } },
16 },
17 })
You can define the following route rule options:
redirect
- Define server-side redirects.ssr
- Disables server-side rendering for sections of your app and make them SPA-only withssr: false
cors
- Automatically adds cors headers withcors: true
- you can customize the output by overriding with headersheaders
- Add specific headers to sections of your site - for example, your assetsstatic
- Enables a single (on-demand) buildswr
- Enables a static build that lasts for a configurable TTL (currently enables full incremental static generation on Netlify, with Vercel coming soon)
For more details, check the corresponding
ππ» Dmitri explains waht ref() is in Vue. |
ππ» Knowing refs is a requirement if you want to understand reactivity in Vue. |
ππ» In our Nuxt apps we have three main ways to get content rendered: Pages, layouts, and components. |
ππ» Michael Thiessen answers the big question: which one should we use, and when? |
ππ» David explains how to implement feature flags in your Vue application using ConfigCatβs feature flagging service.
daveyhert.hashnode.devππ» In this talk Daniel Kelly, discusses practical design patterns for making your large-scale Vue projects more predictable.
www.youtube.comππ» 5.0 is not a disruptive release |
ππ» New decorators standard |
ππ» Better support ESM projects in Node and bundlers |
ππ» New ways for library authors to control generic inference |
ππ» and more... |
ππ» Matt demonstrates that in spite of Manifest v3, a whole lot of bad stuff is still possible when it comes to building browser extensions.
mattfrisbie.substack.comππ» The benefits that come from serverless computing can be lost if you have to spend your time provisioning hardware for your database.
stackoverflow.blogππ» Palette Generator and API for Tailwind CSS. |
ππ» The motivation for this tool is to avoid Tailwindβs built-in color tools that tend to make every project look the same. |
ππ» A CRUD framework for fullstack TypeScript. |
ππ» Promises a βzero-boilerplateβ CRUD API experience by using your TypeScript entities as a single source of truth for your API, frontend type-safe API client and backend ORM. |
ππ» A free platform to test and experiment with variable fonts.
typetrials.comππ» Get dummy/fake JSON data to use as placeholder in development or in prototype testing.
dummyjson.comUntil next week,
Holzapfelkreuther Str. 19, 81375 Munich, Germany