vue-draggable-next is a Vue 3 component that facilitates drag-and-drop functionality within web applications, building upon the robust Sortable.js library. It provides a touch-friendly, lightweight solution for reordering lists and elements, supporting both the Composition API and Options API. The current stable version is 2.3.0. The project maintains an active release cadence, with several updates and fixes in recent months (e.g., v2.2.1, v2.2.0, v2.1.0 since late 2020), indicating ongoing development and bug resolution. Key differentiators include its explicit support for Vue 3's Composition API, built-in TypeScript definitions, a small gzipped footprint (~7kb), and full compatibility with all underlying Sortable.js options, making it a flexible choice for various drag-and-drop scenarios like Kanban boards or reorderable lists.
npm install vue-draggable-nextVerified import paths — ran on the pinned version, not inferred.
This example demonstrates a basic draggable list using Vue 3's Composition API and TypeScript, allowing users to reorder items.
Update all instances of `beforeDestroy` to `beforeUnmount` in your Vue 3 component lifecycle hooks.
Always define a unique `item-key` prop on the `draggable` component, typically corresponding to a unique ID on each item in your `v-model` list (e.g., `:item-key="'id'"`).
Upgrade to `vue-draggable-next` version 2.2.1 or higher to ensure proper TypeScript definition files are included and recognized.
In Composition API, use `ref([])` or `reactive([])` for your list data. In Options API, define your list within the `data` property of your component.
Change `import VueDraggableNext from 'vue-draggable-next'` to `import { VueDraggableNext } from 'vue-draggable-next'`.Ensure your list is strongly typed (e.g., `list = ref<Person[]>()`) and that `item-key` is correctly set, allowing TypeScript to better track item types.
Verify that `vue-draggable-next` is correctly installed and imported, and that your build setup is using a consistent Vue 3 version. Clear node_modules and reinstall dependencies.