SSR and CSR are two ways to show web pages. They decide where the page is made: on the server or in your browser.
SSR vs CSR mental model in Vue
SSR: Server sends full HTML page ready to show. CSR: Server sends minimal HTML and JavaScript; browser builds page.
SSR means the server prepares the page before sending it.
CSR means the browser builds the page after receiving code.
<template>
<h1>{{ message }}</h1>
</template>
<script setup>
const message = 'Hello from SSR!'
</script><template>
<h1>{{ message }}</h1>
</template>
<script setup>
import { ref, onMounted } from 'vue'
const message = ref('Loading...')
onMounted(() => {
message.value = 'Hello from CSR!'
})
</script>This Vue component starts with a message set during server rendering (SSR). When the page loads in the browser, it changes the message (CSR). You see the server message first, then it updates.
<template>
<div>
<h2>SSR vs CSR Demo</h2>
<p>Message: {{ message }}</p>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
const message = ref('Rendered on server')
onMounted(() => {
message.value = 'Updated in browser'
})
</script>SSR helps with faster first page load and better search engine visibility.
CSR allows more interactive and dynamic user experiences.
Many modern apps use a mix: server renders first, then client takes over.
SSR means the server builds the page before sending it.
CSR means the browser builds or updates the page after loading.
Choosing SSR or CSR depends on speed, SEO, and interactivity needs.
Practice
Solution
Step 1: Understand SSR concept
SSR means the server prepares the full HTML content before sending it to the browser.Step 2: Compare with other options
The options describing browser building the page after loading JavaScript and server sending only data describe CSR behavior, while the button-click option is unrelated to SSR.Final Answer:
The server builds the full HTML page before sending it to the browser. -> Option AQuick Check:
SSR = Server builds page first [OK]
- Confusing SSR with CSR
- Thinking SSR means browser builds page
- Assuming SSR only sends data, not HTML
Solution
Step 1: Identify CSR code pattern
CSR usesVue.createApp()to mount app in browser after loading.Step 2: Check other options
export default { ssr: true, setup() { return {} } }mentions SSR flag, C uses SSR app creation, A is just data fetching.Final Answer:
const app = Vue.createApp({ data() { return { count: 0 } } }).mount('#app') -> Option DQuick Check:
CSR uses createApp and mounts in browser [OK]
- Confusing createApp with createSSRApp
- Thinking SSR flag means CSR
- Assuming fetch alone is CSR
Solution
Step 1: Understand SSR output
SSR sends fully rendered HTML, so the user sees content immediately.Step 2: Contrast with CSR behavior
CSR shows blank or spinner until JS runs; SSR avoids this delay.Final Answer:
The fully rendered HTML page visible instantly. -> Option AQuick Check:
SSR = instant HTML visible [OK]
- Thinking SSR waits for JavaScript to load
- Confusing loading spinner with SSR
- Assuming SSR causes errors on load
Solution
Step 1: Understand SSR delivery
In SSR, the server must send fully rendered HTML; a blank page indicates the server rendered no content or sent empty HTML.Step 2: Rule out client-side issues
Hydration failure leaves static HTML visible; no JS support shows static HTML; using createApp may cause flicker but content appears.Final Answer:
The server did not send any HTML content. -> Option BQuick Check:
Blank SSR page = no HTML from server [OK]
- Thinking hydration failure causes blank (leaves static HTML)
- Blaming browser JS support (shows static without JS)
- Assuming createApp causes blank (re-renders on client)
Solution
Step 1: Analyze requirements
Fast initial load and SEO need server-rendered HTML visible to search engines.Step 2: Match approach to needs
SSR renders HTML on server, improving SEO and load speed; hydration enables interactivity.Step 3: Evaluate other options
CSR delays content rendering, SSR without hydration loses interactivity, CSR with JSON only delays content.Final Answer:
Use SSR to render the page on the server, then hydrate on client. -> Option CQuick Check:
SSR + hydration = fast load + SEO + interactivity [OK]
- Choosing CSR only for SEO needs
- Disabling hydration losing interactivity
- Assuming JSON data alone improves SEO
Ready to prove it?
Pass the test and this pattern moves unknown
