@macrulez/masonry-kit-nuxt

Nuxt module wrapping @macrulez/masonry-kit-vue: auto-imported and useMasonry, module options for default layout behavior
857
Install
npm install @macrulez/masonry-kit-nuxt
Latest Version:0.1.4
Vue:3
License:MIT
Last Updated:Sep 21, 2026
Links: npm
Maintainer: macrulez

Masonry Kit Nuxt

Masonry Kit Nuxt

Nuxt module wrapping @macrulez/masonry-kit-vue: auto-imported <MasonryGrid>/useMasonry, a universal plugin that seeds their option defaults from your nuxt.config.ts, and no manual <ClientOnly> wrapping needed — the component is already SSR-safe on its own, rendering a CSS columns approximation until it can measure for real.

Part of the masonry-kit monorepo.


Features

  • Auto-imports <MasonryGrid> and useMasonry — no explicit import anywhere in your app
  • Module options forwarded through runtimeConfig — direction, columns, rows, minLaneSize, gap, placement, animate, transitionDuration, transitionEasing, ssrColumns, set once in nuxt.config.ts and applied everywhere
  • A universal (server + client) plugin seeds those defaults — most option defaults only matter once the engine exists client-side, but ssrColumns is read directly by <MasonryGrid>'s render function, which runs during SSR too — so the plugin isn't .client-only
  • No <ClientOnly> needed anywhere — <MasonryGrid> renders a CSS columns approximation server-side and switches to the real transform-based layout the moment it measures on the client, in the same frame

When you'd reach for this

You're already on Nuxt and want <MasonryGrid>/useMasonry wired up with zero manual setup — auto-imports, and one place to configure defaults instead of passing the same options at every call site.

  • Passing the same gap/columns to every single <MasonryGrid> on the site gets old — Set them once in nuxt.config.ts and every instance that doesn't override them picks up your project's defaults automatically.
  • You'd rather not remember to import <MasonryGrid> in every component — Auto-imports mean it's just available, the same way Nuxt's own built-ins are.
  • A team member reaches for <ClientOnly> out of habit — There's nothing to wrap; the component already renders a safe SSR approximation and swaps to the real layout after hydration on its own.

Installation

npm install @macrulez/masonry-kit-nuxt
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@macrulez/masonry-kit-nuxt'],
  masonry: {
    columns: 'auto',
    minLaneSize: 240,
    gap: 16,
  },
})

Requires Nuxt ^3.9.0 || ^4.0.0.

Quick start

Once the module is registered, just use the component — no imports:

<template>
  <!-- <MasonryGrid>/useMasonry are auto-imported -->
  <MasonryGrid :items="items">
    <template #item="{ item }">
      <MyCard :data="item" />
    </template>
  </MasonryGrid>
</template>

See @macrulez/masonry-kit-vue's README for the full <MasonryGrid>/useMasonry API — props, slots, sortable, virtualization, and more.

More examples

What the module does
  1. Auto-imports <MasonryGrid> and useMasonry from @macrulez/masonry-kit-vue — no explicit import needed in your components.
  2. Forwards module options (direction, columns, rows, minLaneSize, gap, placement, animate, transitionDuration, transitionEasing, ssrColumns) into runtimeConfig.public.masonry.
  3. Registers a universal plugin that reads that runtime config and calls setMasonryDefaults(...) — so every <MasonryGrid>/useMasonry use that doesn't pass its own options picks up your configured defaults.
Module options
Option Falls through to
direction core's own default ('vertical') when unset
columns / rows core's own default ('auto') when unset
minLaneSize core's own default (240) when unset
gap core's own default (16/16) when unset
placement core's own default ('balanced') when unset
animate core's own default (true) when unset
transitionDuration core's own default (250) when unset
transitionEasing core's own default when unset
ssrColumns columns/rows (if concrete), else a conservative 2

None of these are hardcoded in the module itself — an option you don't set stays undefined all the way through to @macrulez/masonry-kit-core's own default, so a future change to core's default keeps applying automatically for Nuxt consumers too.

Overriding defaults per instance

Module options are the fallback, not a ceiling — any <MasonryGrid :options="..."> prop still wins for that one instance:

<template>
  <MasonryGrid :items="items" :options="{ columns: 2 }">
    <!-- uses 2 columns here, regardless of the module-wide default -->
    <template #item="{ item }">
      <MyCard :data="item" />
    </template>
  </MasonryGrid>
</template>

Documentation & links


License

MIT


💖 Support the project

Open source takes time and effort. If this library saves you time or brings value, consider supporting further development.

Donate via CryptoCloud

Thank you for being part of this journey. ❤️

Related Packages

@macrulez/vue-form-schema

Reactive Vue 3 forms generated from JSON, Zod, Yup or Valibot schemas, with vali...

2,714 0
@macrulez/vue-state-machine

Reactive finite state machines and statecharts for Vue 3 — declarative transitio...

2,677 0
@macrulez/vue-command-palette

Headless Command+K palette for Vue 3 with fuzzy search, grouped and nested comma...

2,330 0
@macrulez/inview-vue

Vue 3 composables for scroll, visibility and viewport-position tracking

1,014
@macrulez/inview-nuxt

Nuxt module wrapping @macrulez/inview-vue: auto-imported composables/core engine...

963

Version History

Version Released Vue License
0.1.4 ^3.0 MIT
0.1.3 ^3.0 MIT
0.1.2 ^3.0 MIT
0.1.1 ^3.0 MIT
0.1.0 ^3.0 MIT