Nuxt.js — Best practices for client-side-only contents (client-only / no-ssr)

Liu Ting Chun
3 min readNov 9, 2019

Not all third party components support server side rendering (SSR). Nuxt.js provides a way for you to exclude those components from the server side rendering phase, which is the <client-only> or <no-ssr> (deprecated) tag.

<template>
<div>
<client-only>
<carousel v-bind:perPage="2">
<slide
v-for="imgUrl in imgUrls"
v-bind:key="imgUrl">
<img v-bind:src="imgUrl">
</slide>
</carousel>
</client-only>
</div>
</template>

When you do this, all the contents within the <client-only> tag will not be rendered during SSR. Those contents will be rendered in the client side after the Vue instance is initialized in the user’s browser. For best practices, here is the decision point that you should consider when using the <client-only> tag — Are contents inside important for SEO?

If contents are important for SEO

Most search engine crawlers do not execute JS when they do the crawling. (Only Google will execute JS as I know.) As a result, the Vue instance is never initialized and those contents will not be visible to crawlers. To deal with this, you should add placeholders, which are displayed before those client-only contents are rendered. The Vue instance will replace the placeholder with the client-only contents once they are loaded.

<template>
<div>
<client-only>
<carousel…

--

--

Liu Ting Chun
Liu Ting Chun

Written by Liu Ting Chun

Web developer from Hong Kong. Most interested in Angular and Vue. Currently working on a Nuxt.js + NestJS project.