Skip to content

upgrade: clipboard package upgrade for Solid 2.0#850

Draft
davedbase wants to merge 1 commit intosolidjs-community:nextfrom
davedbase:update/v2/clipboard
Draft

upgrade: clipboard package upgrade for Solid 2.0#850
davedbase wants to merge 1 commit intosolidjs-community:nextfrom
davedbase:update/v2/clipboard

Conversation

@davedbase
Copy link
Copy Markdown
Member

Migrates the clipboard package to Solid.js 2.0 (beta.7).

Breaking changes

  • createClipboard now returns an async accessorcreateResource (removed in 2.0) is replaced with an async createMemo. The returned clipboard accessor starts synchronously with an empty array; after refetch() it reads from the clipboard asynchronously. The previous value stays visible during a pending read (isPending(() => clipboard()) returns true).

  • copyToClipboard directive → ref function — Solid 2.0 no longer supports the use: directive namespace extension pattern. copyToClipboard is now a factory that returns a ref callback:

    // before
    <input use:copyToClipboard />
    
    // after
    <input ref={copyToClipboard()} />
    <button ref={copyToClipboard({ value: "copy me" })}>Copy</button>

    The declare module "solid-js" JSX directive augmentation has been removed accordingly.

  • isServer import — moved from solid-js/web@solidjs/web.

  • Peer dependency bumped to solid-js@^2.0.0-beta.7.

Internal

  • Extracted readClipboardItems() async helper (replaces inline on+createResource pattern).
  • Fixed a long-standing typo in the element tag check: "texfield" → ``"textarea"`.
  • copyToClipboard now uses @ts-expect-error instead of @ts-ignore.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

🦋 Changeset detected

Latest commit: c05d43f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solid-primitives/clipboard Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@davedbase davedbase changed the base branch from main to next April 21, 2026 01:46
@davedbase davedbase added this to the Solid 2.0 Upgrade milestone Apr 21, 2026
import { isServer } from "solid-js/web";
// isServer moved from solid-js/web (1.x) to @solidjs/web (2.x).
// typeof window is a universal fallback compatible with both versions.
const isServer = typeof window === "undefined";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe globalThis.window !== globalThis instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants