0
0
Vueframework~10 mins

Why SSR matters for Vue - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a basic Vue app instance.

Vue
const app = Vue.[1]({
  data() {
    return { message: 'Hello SSR!' };
  }
});
Drag options to blanks, or click blank then click option'
AcreateApp
BmountApp
CnewApp
DinitApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mountApp' instead of 'createApp'
Trying to use 'newApp' which is not a Vue function
2fill in blank
medium

Complete the code to mount the Vue app to the DOM.

Vue
app.[1]('#app');
Drag options to blanks, or click blank then click option'
Aattach
Brender
Cstart
Dmount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'render' which is for rendering components, not mounting
Using 'attach' which is not a Vue method
3fill in blank
hard

Fix the error in the server entry file to enable SSR rendering.

Vue
import App from './App.vue';

export function createApp() {
  const app = [1](App);
  return { app };
}
Drag options to blanks, or click blank then click option'
AcreateSSRApp
BstartSSR
CmountApp
DrenderToString
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'createApp' which is for client-side only
Using 'renderToString' as a function name here
4fill in blank
hard

Fill both blanks to complete the Vue SSR server setup.

Vue
import { [1] } from 'vue/server-renderer';
import { createSSRApp } from 'vue';

export async function render(url) {
  const app = createSSRApp({ /* root component */ });
  const html = await [2](app);
  return html;
}
Drag options to blanks, or click blank then click option'
ArenderToString
BrenderToStaticMarkup
CrenderToDom
DrenderApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'renderToDom' which is client-side only
Using different functions for import and call
5fill in blank
hard

Fill all three blanks to complete a Vue SSR hydration example.

Vue
import { [1] } from 'vue';
import App from './App.vue';

const app = [2](App);
app.[3]('#app');
Drag options to blanks, or click blank then click option'
AcreateSSRApp
BcreateApp
Cmount
Dhydrate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'createApp' which is not optimized for hydration
Using 'mount' instead of 'hydrate' for SSR content