Epicmax
Vue.js TalksSeptember 11, 2024·10 min read· by Epicmax Team

Vue.js Talks #1 Recap: Vuestic Compiler, SOLID in JavaScript and Hydration Errors

Recap and full recording of Vue.js Talks #1: the Vuestic UI compiler and devtools, SOLID principles in JavaScript (part 1), and hydration errors in Vue SSR.

EventsVue.js

Vue.js Talks #1 took place online on September 11, 2024. It was the first meetup in the series, run by the Vuestic UI team at Epicmax for Vue developers of any level. Three talks were on the agenda: Maksym Nedoshev presented the Vuestic compiler and the new Vuestic devtools, Dmitry Raichev started a series on SOLID principles in JavaScript, and Pavel Mironov explained where hydration errors in Vue SSR come from and how to avoid them.

The full recording is above. Below is a summary of each talk with timestamps, so you can jump straight to the part you care about.

Vuestic compiler: moving framework work to build time

Speaker: Maksym Nedoshev, Lead Developer of Vuestic UI at Epicmax · watch from 1:00

Maksym started with where Vuestic UI stands today: over 50 components, each customizable with CSS variables; global settings for colors, icons and breakpoints; and a preset system that can store a component's props, classes, styles, slot text and even components for slots. On top of that come validation, masks, and integrations with projects like Tailwind and auto-import plugins.

All of that has a cost. A large framework affects bundle size and runtime performance, and developers have to learn its features before they save time. The Vuestic compiler is the team's answer: move some framework features from runtime to build time.

Smaller bundles without code changes

Maksym's example was a date input. It is made of several features: the input field with its styles, icons and hover effects, a dropdown with a calendar, and a date mask. When a component gets a mask prop, the mask feature is obviously in use. When no instance uses it, the compiler can detect that and remove the mask code from the output bundle. The plan is to apply this build-time optimization to most components, and it needs no changes to your code.

The compiler also makes a clean theme possible: only the essential positioning styles, so teams that want to style everything from scratch don't have to override the default theme first. That means a smaller bundle and no fighting existing classes.

Developer experience

  • Less setup. Today, using Vuestic with something like Tailwind means reading docs and configuring the project. The plan is for the compiler to check whether Tailwind is installed and configure Vuestic and Tailwind to work together in dev and build. You install the packages and start building.
  • Generated types for icons, colors, i18n strings and presets, so the IDE can suggest them and you don't have to remember what is in your config.
  • Devtools in the browser. A built-in, visual way to edit your app: change component props, edit slot text, adjust layout settings, and add or remove components. It edits your local code, so you keep working on your own branches.

Further plans include a presets editor in the devtools, possibly a backend integration, and an AI assistant where you can ask something like "make this button red and add an icon". The compiler is still in development; the devtools can already be tried, and the team asked for feedback and feature requests on the Vuestic docs and Discord.

Q&A highlights

  • What does "backend integration" mean? Integration with your API endpoints. In theory the devtools could scan the API routes you have and let you wire, for example, a click event to an endpoint from a list of available ones.
  • Can the clean theme apply to only some components (styled buttons, but a clean calendar)? Yes. The goal is to allow it per component, not only globally: in Maksym's experience, some Vuestic components match a project's design as they are and others need to look completely different.
  • Why devtools if HMR already shows changes instantly? Maksym agreed that writing code can be faster for frontend developers. The devtools are meant more for backend developers and teammates who don't want to learn every prop: they see the options on screen, for example a color picker with previews, instead of keeping the docs in their head.
  • Will Vuestic stay open source? Pavel, the host, said it is free and open source with no paid option, and there are no plans to change that.

Rethinking SOLID principles in JavaScript, part 1

Speaker: Dmitry Raichev, Software Engineer at Epicmax · watch from 15:00

Dmitry noted that SOLID was introduced around 2000 to help write software that survives constantly changing requirements while staying reliable and easy to maintain. The original work focused on object-oriented languages, and more than 20 years later there is still little material on applying it to JavaScript and frontend development. He didn't claim to fill that gap, but shared examples from real projects. This talk covered the first three principles: single responsibility, open/closed and Liskov substitution. Interface segregation and dependency inversion came in part 2 at Vue.js Talks #3.

Single responsibility

Every software entity should have one responsibility. Applied to components, Dmitry splits them into four types:

  • Layouts: the main structure of a page, reused by every view that shares it.
  • Pages (views): one per route. A view gets the application context and the resources it consumes directly, and assembles the components that present the content. It does not orchestrate state, behavior or communication between its children; that work is delegated. It passes only presentation props such as booleans or style values, and state and actions are resolved by the component that actually uses them.
  • Composing components: bundle a feature out of nested components, following the same rules.
  • Atomic components: the building blocks, as "dumb" as possible.

This sounds obvious, but it is easy to break. Dmitry's example was a composable, say useCategory, that loads products for a product list page but also starts the loader, decides how to show error messages and knows about the view. The composable knows too much, and so does the page, whose only job should be arranging elements.

The refactor reduces the composable to one purpose: abstracting the API layer that fetches and updates products. Dedicated components do their own work instead of filling the page's state. The page passes simple flags, such as whether to show error messages or recommendations (usually from feature flags or other configuration), plus style props. When components need to talk to each other, a separate abstraction handles it, such as an event bus or provide/inject. Because each component holds its own logic, you can move it around without breaking anything.

Open/closed

Software entities should be open for extension but closed for modification. Dmitry's example was a component that shows a user's full name. That logic is unlikely to change, and even if the markup changes or the data source switches to a different integration, you shouldn't have to rewrite the script. So the component reads the name through a separate abstraction layer for user data. Switching integrations means writing a new implementation of that layer, not touching the component.

Liskov substitution

The central idea here is design by contract. Dmitry illustrated it with his recent project: a company that owns several apparel, footwear and accessories brands, each with its own technical specifics and design, all sharing one codebase. When the app is built for one brand, code for the other brands must not end up in it.

Simplified, the project has a folder per brand (in his example, epicmax and a white-label wl) next to a core folder, all with the same structure. core holds everything that must work out of the box, including the contracts the app depends on. A product list component in core renders product cards, but each brand's card looks different. Instead of changing core code, the right brand's card is substituted at build time. The only requirement is that every substitute follows the same contract.

In a large project, you can help other developers keep to the pattern with generator scripts that scaffold brand components with the required bindings, or with ESLint rules that check the contract. Besides making the code more resilient, this keeps code for other brands out of the bundle so it can be tree-shaken properly.

Q&A highlights

  • Why not keep a "get user data" helper in the composable instead of repeating it in every component? Because if the API or integration changes, you have to go back and rewrite the composable. With the data layer separated, a simple composable can be written once and left alone. Sometimes it is better to be a little less DRY than to rewrite code that already works and is tested. Testing came up as a further reason: a composable that pulls in many others forces you to mock all of them to test it.
  • Isn't that the whole idea of composables? Composables are one mechanism for abstraction. Their main benefit is making explicit what is exposed; with mixins it was often unclear where a method or property came from. The principles are about abstractions; a composable is a mechanism, not a principle.
  • Where can I read about SOLID with Vue? There are few articles on SOLID for JavaScript and Vue, which is why Dmitry prepared the talk. He planned to cover the remaining principles with live coding next time and to collect the material into an article.

Understanding and solving hydration errors in Vue.js

Speaker: Pavel Mironov, Vue.js Developer at Epicmax · watch from 36:00

Pavel, who also hosted the meetup, works on large e-commerce projects at Epicmax. His talk covered what hydration is, why server-side rendering matters, why hydration mismatches are a problem, the common causes, and how to avoid them.

How SSR and hydration work

Hydration is the process that turns static, server-rendered HTML into an interactive page by attaching Vue on the client. Like adding water to something dry, it brings the page to life. It happens after the initial server-side render and lets users interact with the page without waiting for a full client-side render.

With SSR, the server runs the Vue app (on Node.js, directly or through a framework like Nuxt), renders the components into HTML strings and sends them in the response. The browser shows that HTML right away, which gives faster initial page loads and helps SEO. Pavel's example was an e-commerce product listing that customers should see as fast as possible, with extras like add-to-cart animations and slideshows arriving once Vue takes over.

On the client, Vue builds the virtual DOM from the component tree and compares it with the HTML that is already there. If they match, Vue attaches its reactivity, such as event listeners and data bindings, to the existing DOM elements without re-rendering. The key point: every component renders twice, once on the server and once on the client.

Why mismatches hurt

In Pavel's description, when the two renders don't match, the client has to discard the server output and rebuild the HTML. He listed the consequences:

  • Wasted server work, since the client redoes it.
  • A flash of incorrect UI: content shifting or blinking.
  • SEO and Core Web Vitals problems, depending on how much of the page is affected.
  • Slower pages and higher resource and CPU usage on the client, especially on large or dynamic pages.
  • Extra network usage if the client has to fetch data or assets again.
  • JavaScript errors, especially from third-party libraries that depend on component state, and they are painful to debug.
  • Inconsistent state and potential accessibility issues.

Common causes

  • Different HTML on server and client. A timestamp rendered on the server won't match the one rendered on the client a moment later. Pavel's second example was a v-if on a component's root element, where he suggested v-show instead, because v-show keeps the element in the DOM and only hides it.
  • Timing and browser-only APIs. Code that relies on window behaves differently, since the server has no window at all.
  • State out of sync. Async requests that return different data on the server and the client produce different markup.

Best practices

  • Don't render random or time-sensitive values during SSR. Render a fixed value on the server and update it on the client after hydration, in a lifecycle hook such as onMounted. For example, show a placeholder for "current time" and fill it in on mount.
  • Fetch data on the server before rendering, so the HTML already contains the content. Use onMounted on the client only for client-specific updates, for example refreshing part of a user profile after hydration.
  • Prefer CSS media queries to JavaScript breakpoints. Breakpoint services in some UI frameworks rely on window, which doesn't exist during SSR. Media queries are applied by the browser during rendering, so the server HTML and the client layout stay consistent. Utility-first CSS frameworks like UnoCSS or Tailwind make this easy with responsive classes.

The first practice looks roughly like this (an illustrative example, not code from the talk):

<script setup lang="ts">
import { onMounted, ref } from 'vue'

// Server and client render the same placeholder, so hydration matches.
const loadedAt = ref<string | null>(null)

onMounted(() => {
  loadedAt.value = new Date().toLocaleTimeString()
})
</script>

<template>
  <p>Loaded at {{ loadedAt ?? '…' }}</p>
</template>

Q&A highlights

  • Can a CDN cache cause mismatches? One attendee pointed out that caching on a CDN like Netlify can cause a mismatch when the data wasn't fetched in time. Pavel agreed.

Join the next Vue.js Talks

Vue.js Talks is a free online meetup for the Vue.js and open-source community. Recordings of every meetup are on the Vue.js Talks YouTube channel, and you can read more about the series on the Vue.js Talks page. Want to speak? First-time speakers are welcome; submit your talk here.

Vue.js is our passion. Open Source is our culture 😍