Porting svelte-dnd-action to Svelte 5 without breaking the drag and drop A developer has published @lukez/svelte-dnd, a hard fork of Isaac Hagoel's svelte-dnd-action 0.9.80 rebuilt for Svelte 5 with a fully breaking public API and no compatibility layer for Svelte 3/4. The port was done in staged steps with the upstream test suite kept green throughout, and Claude Code performed almost all of the implementation work under the developer's direction. The fork retains the original MIT copyright and full git history, and the developer notes that svelte-dnd-action itself still works on Svelte 5 and is maintained. svelte-dnd-action by Isaac Hagoel has been the drag and drop library for Svelte since 2020. It handles pointer, touch and keyboard drags, screen reader announcements, auto-scrolling, nested zones, drag handles, flip animations, and since 0.9.80 even zones in same-origin iframes and popups. A lot of hard-won edge-case handling lives in that code. @lukez/svelte-dnd is a hard fork of svelte-dnd-action 0.9.80, rebuilt for Svelte 5. This post covers why the fork exists, how it was ported without losing that edge-case handling, and what the API looks like now. The drag and drop engine in @lukez/svelte-dnd is Isaac Hagoel's work. The fork keeps the full git history, and the LICENSE keeps his MIT copyright line Copyright c 2020 Isaac Hagoel above the new one. If you are happy on svelte-dnd-action , there is no reason to switch: it still works with Svelte 5 and is maintained. The port itself I couldn't have done without Claude. Claude Code did almost all of the implementation work. I had to be there the whole time to guide the agents and make the decisions, but the code changes were theirs. Upstream puts API stability first. That is a good call for a library with many users on Svelte 3 and 4, but it means the public surface stays what it was in the Svelte 3 era: use:dndzone action, consider and finalize as DOM CustomEvent s, read through e.detail , setAriaStrings , setDebugMode , overrideItemIdKeyNameBeforeInitialisingDndZones , ... , Svelte 5 has attachments {@attach} and callback props, and the rest of a Svelte 5 codebase looks like that. Changing upstream to match would break every existing user, which is what upstream avoids. Semver would allow a new major next to a maintained old one, but that is a lot of work for one maintainer, so I get why Isaac hasn't done it. Most sites still on Svelte 3 or 4 stay there because their owners are too stubborn to migrate, if you ask me. If you just want to keep a website working on old software, that's fine, and I like people who keep older things supported. But the number of people who want a more modern version of this library keeps growing. The old API does still work on Svelte 5, especially with fromAction , which turns an action into an attachment. My guess is that actions won't be around forever, though. If Svelte announces that they are going away, I would rather already have a native implementation than scramble through the code at the last minute to write one, if anyone writes one at all. So the fork takes the other trade: a full breaking rewrite of the public API, published under a new name, with no compatibility layer for svelte-dnd-action or Svelte 3/4. The goals, from the migration plan: The last goal mattered most. The rest was plumbing. A rewrite from scratch would have thrown away the safety net: most existing specs test internals listUtil , styler , util , so they would not survive a redesign, and new tests only cover what their author thought of. So the port went in stages, with every test green at the end of each one. That costs some throwaway work stage 3 carefully types code that stage 4 then changes or even removes , but every risky step has the old test suite behind it. The first stage changed everything around the library and nothing inside it: packages/svelte-dnd moved with pure git mv commits, so history follows publint and attw @arethetypeswrong/cli , which catches broken dual ESM/CJS types next tag I picked these mostly because I use them in my other projects and like working with them, though there were a few technical reasons too. Cypress, the upstream test runner, kept running the whole time. A regression found later must never come from the tooling swap. One rule from upstream got special care: a lint rule that forbids window , document , setTimeout and similar globals in src/ . It exists because zones can live in other windows, so the code must always use the globals of the node's own document. ESLint's no-restricted-globals was carried over to oxlint unchanged. Stage 2 moved all 15 Cypress specs 150 tests to Vitest browser mode on Playwright, running Chromium, Firefox and WebKit. The rule was: same scenarios, same assertions, same synthetic events. Only the harness changes. Cypress uses Chai assertions, and Vitest's expect supports the Chai API, so assertions were copied verbatim instead of being rewritten in Jest style. The translations were mechanical: | Cypress | Vitest | |---|---| | cy.then = { ... } chains | sequential code in an async test | | cy.window .should = { ... } | await vi.waitFor = { ... }, { timeout: 4000 } | | cy.stub obj, "m" .callsFake fn | vi.spyOn obj, "m" .mockImplementation fn | Specs were ported one per commit, with Cypress and Vitest both running in CI until the last spec moved, so no commit was red. Before Cypress was removed, a script listed every describe it title from the old specs next to its Vitest result per browser, and compared the expect count per file. Every original title had to be present. Switching to userEvent , fake timers, or a more idiomatic style was explicitly rejected for this stage. It would have changed what the tests exercise, and the point was to keep them testing the same thing. Upstream 0.9.80 added zones in same-origin iframes and popups. The Cypress harness for this opened real popups, but CI ran Cypress on Electron, which blocks window.open , so the popup tests always skipped themselves in CI. Under Vitest, each test file already runs inside an iframe of the runner's page. The createFrame helper builds a frame nested inside that, which keeps the parent/child relationship the specs rely on. The other-window spec was ported first as a spike, to confirm on all three browsers that popups open from the test iframe and that the timing still holds. It did, and from then on the iframe and popup tests ran for real. They found a bug on the first run. In Firefox, a keyboard-enabled zone in a document written with document.write and document.close never got its screen reader instructions. initAria set them up right away only when readyState === "complete" , and otherwise waited for DOMContentLoaded . After document.close , Chromium and WebKit report "complete" , but Firefox reports "interactive" , and DOMContentLoaded has already fired by then. So the listener never ran. Stage 2 did not fix it, because stage 2 was not allowed to touch src/ . The failing tests were marked it.fails on Firefox only so they would alert once fixed , and the bug became issue 2. The fix was small: set up immediately whenever readyState == "loading" . Stage 3 converted src/ and the tests to TypeScript, strict mode, with isolatedDeclarations so tsdown could generate .d.mts and .d.cts declarations. The hand-written typings/index.d.ts was deleted. Files were converted leaves first constants , helpers/util , ... , entry points last, with allowJs so .ts and .js could coexist and every commit stayed green. The rule for each file: types only. Where strict mode wanted a null check the code never did, the conversion used a non-null assertion with a comment, not a runtime guard. If the value really could be null , that was a bug, and it got an issue and a TODO n instead of a quiet fix. Two such issues came out of it: findWouldBeIndex caches the shadow element's rect per zone and index. The cache outlives the shadow element moving to another zone, so the function can return { index: undefined } even though its type says number . dzToConfig.get e.currentTarget , which is undefined when a zone nested inside the dragged item is destroyed mid-drag. An upstream issue isaacHagoel/svelte-dnd-action 450 reports a similar crash, closed without a reproduction. Both were fixed after stage 3, each on its own fix/ branch with a regression test, before the API rewrite started. The declaration diff was useful on its own. It showed that the hand-written typings had drifted from the runtime: for example, FEATURE FLAG NAMES.USE COMPUTED STYLE INSTEAD OF BOUNDING RECT was typed as the string "FEATURE FLAG NAMES.USE COMPUTED STYLE INSTEAD OF BOUNDING RECT" , while the runtime value is "USE COMPUTED STYLE INSTEAD OF BOUNDING RECT" . Generated types end that class of bug. This is the breaking change. A zone used to look like this: js