@modular-vue/core
| Install | |
|---|---|
npm install @modular-vue/core |
|
| Latest Version: | 1.5.0 |
| Vue: | 3 |
| Last Updated: | Oct 13, 2026 |
| Links: | GitHub · npm |
@modular-vue/core
Core types and utilities for defining modules using vue-router. Provides defineModule, the shared composables and scoped stores from @modular-vue/vue, and all shared type definitions.
Installation
npm install @modular-vue/core
What's included
- Module definition:
defineModule,defineSlots - Types:
ModuleDescriptor(with vue-routerRouteRecordRawsupport),AnyModuleDescriptor(router-narrowed shorthand for internal plumbing),LazyModuleDescriptor,NavigationItem,ModuleLifecycle,ReactiveService,SlotMap,SlotMapOf,ZoneMap,ZoneMapOf - Shared dependencies:
sharedDependenciesKey,provideSharedDependencies,createSharedComposables(returnsuseStore,useService,useReactiveService,useOptional) — re-exported from@modular-vue/vue - Scoped stores:
createScopedStorewithuseScopedcomposable — re-exported from@modular-vue/vue - Route meta:
ModuleRouteMeta, the convention for carrying zones and per-route static data onroute.meta - Detection:
isStoreApi,isReactiveService,separateDeps
Usage
import { defineModule } from "@modular-vue/core";
export default defineModule<AppDependencies, AppSlots>()({
id: "billing",
version: "0.1.0",
createRoutes: () => [
{
path: "/billing",
children: [
{
path: "",
component: () => import("./pages/BillingDashboard.vue"),
},
],
},
],
navigation: [{ label: "Billing", to: "/billing", group: "finance" }],
// Static slots (always present)
slots: { commands: [{ id: "billing:export", label: "Export", onSelect: () => {} }] },
// Dynamic slots (re-evaluated on recalculateSlots())
dynamicSlots: (deps) => ({
commands:
deps.auth.user?.role === "admin"
? [{ id: "billing:void", label: "Void Invoice", onSelect: () => {} }]
: [],
}),
});
Unlike the frozen-tree routers, vue-router lets the runtime graft a module's
routes in via router.addRoute(), so createRoutes() returns a full
RouteRecordRaw subtree for both eager and lazy modules.
Typed route.meta
Zones and per-route static data ride on a route's meta. Augment vue-router's
global RouteMeta once in your app to get typed access everywhere the runtime
reads it:
import type { ModuleRouteMeta } from "@modular-vue/core";
import type { AppZones } from "@myorg/app-shared";
declare module "vue-router" {
interface RouteMeta extends ModuleRouteMeta<AppZones> {}
}
See the main documentation for the full guide.
Related Packages
Nuxt 4 integration for @modular-vue: a Nuxt module plus a runtime installer that...
vue-router runtime for @modular-vue modules: createRegistry with module registra...
Vue 3 journeys for @modular-vue: JourneyProvider, instance composables (useJourn...
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.5.0 | ^3.5.40 | ||
| 1.4.1 | ^3.5.40 | ||
| 1.4.0 | ^3.5.40 | ||
| 1.3.0 | ^3.5.40 | ||
| 1.2.0 | ^3.5.40 | ||
| 1.1.0 | ^3.5.40 | ||
| 1.0.1 | ^3.5.40 | ||
| 1.0.0 | ^3.5.40 |