Skip to content

upgrade: cookies package upgrade for Solid 2.0#906

Open
davedbase wants to merge 3 commits into
solidjs-community:nextfrom
davedbase:update/v2/cookies
Open

upgrade: cookies package upgrade for Solid 2.0#906
davedbase wants to merge 3 commits into
solidjs-community:nextfrom
davedbase:update/v2/cookies

Conversation

@davedbase
Copy link
Copy Markdown
Member

@davedbase davedbase commented May 21, 2026

Upgrades the cookies package to Solid 2.0 (beta.13), adds a full test suite, and clarifies the intended relationship between this package and @solid-primitives/storage.

Changes:

  • isServer and getRequestEvent imported from @solidjs/web (was solid-js/web)
  • createEffect converted to the required split compute/apply form — reactive tracking of the serialized value is now separated from the document.cookie write
  • createSignal initial value cast to Exclude<T | undefined, Function> to satisfy Solid 2.0's strict overload that distinguishes value signals from derived writable signals
  • Peer dependencies updated to solid-js@^2.0.0-beta.13 and @solidjs/web@^2.0.0-beta.13
  • 19 browser tests and 6 SSR tests added covering all exported primitives
  • package.json description and README updated to clarify scope

Architectural note — this package should use @solid-primitives/storage

@solid-primitives/cookies currently hand-rolls its own cookie read (parseCookie / getCookiesString) and write (document.cookie = ...) logic. The right foundation for this is cookieStorage from @solid-primitives/storage, which already provides a battle-tested, isomorphic localStorage-compatible cookie API with full attribute support (domain, path, secure, sameSite, httpOnly, expires, maxAge).

Once @solid-primitives/storage is migrated to Solid 2.0, this package should be updated to:

  • Replace parseCookie / getCookiesString reads with cookieStorage.getItem()
  • Replace the raw document.cookie = write in the effect with cookieStorage.setItem()
  • Expand ServerCookieOptions to extend CookieOptions from storage, exposing the full attribute surface to callers

The blocker is that @solid-primitives/storage is currently still on solid-js@^1.6.12. Pulling it in now would create a version conflict. This PR intentionally defers the integration and documents it in the README so the dependency is tracked at the intent level until storage is ready.

Summary by CodeRabbit

  • Chores

    • Updated package to require Solid.js v2.0 beta 13 as a peer dependency; this is a breaking change for users on earlier Solid versions.
  • Documentation

    • Improved README clarity on reactive, signal-based cookie behavior for both client and server environments.
  • Tests

    • Added comprehensive browser and SSR test suites covering cookie parsing, creation, serialization, and theme management.

Review Change Stack

@davedbase davedbase added this to the Solid 2.0 Migration milestone May 21, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

🦋 Changeset detected

Latest commit: 12c3078

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/cookies 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 marked this pull request as draft May 21, 2026 12:49
@davedbase davedbase marked this pull request as ready for review May 23, 2026 16:05
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bf942942-624c-47ee-a6f9-001ebc6e60c3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cookies/src/index.ts`:
- Around line 69-78: The effect currently calls serialize(cookie()) even when
cookie() is undefined, causing the string "undefined" to be stored; update the
createEffect callback to guard against undefined: if cookie() is undefined,
clear the cookie (e.g., write document.cookie = `${name}=;max-age=0` or
otherwise delete/skip) instead of calling serialize, otherwise call
serialize(cookie()) and write the cookie as before; reference createSignal
(cookie), createEffect, serialize, name and cookieMaxAge to locate and modify
the logic so serialize is never invoked with undefined.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 352a792e-2ae0-4bbc-bc47-baf6df1ffc7b

📥 Commits

Reviewing files that changed from the base of the PR and between 8e8ff1e and 2ca051c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • .changeset/cookies-solid2-migration.md
  • packages/cookies/README.md
  • packages/cookies/package.json
  • packages/cookies/src/index.ts
  • packages/cookies/src/test/index.test.ts
  • packages/cookies/src/test/server.test.ts

Comment thread packages/cookies/src/index.ts
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.

1 participant