Skip to content

Conversation

@mjackson
Copy link
Member

@mjackson mjackson commented Nov 6, 2025

This PR adds a new @remix-run/session package and a session middleware to fetch-router.

It's a complete rewrite of the session handling code we currently have in Remix v2 and RR v7. The main motivations for this work were:

  • Less ceremony around session storage creation
  • More powerful session management API that supports regenerating IDs and smarter/automatic handling of session.flash() values
  • Add FileSessionStorage for storing sessions on the filesystem

This PR closes #10790 and #10794, and supersedes #10811

@mjackson mjackson force-pushed the session branch 2 times, most recently from 09ba3d0 to a28d440 Compare November 6, 2025 06:54
@MichaelDeBoey MichaelDeBoey linked an issue Nov 6, 2025 that may be closed by this pull request
Copy link
Contributor

@brophdawg11 brophdawg11 left a comment

Choose a reason for hiding this comment

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

Looks good! I like the cleaner decoupling of the cookie/session and the new storage APIs of update/delete instead of commitSession/destroySession 👍

Comment on lines +116 to +118
get size(): number {
return this.#valueMap.size + this.#flashMap.size
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we end up using this for anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah, I ended up adding a context.sessionStarted flag instead and issuing a warning if someone starts using context.session without a session() middleware in the stack since it's a no-op. I still think session.size is a nice-to-have though, so I left it in.

@mjackson mjackson merged commit bc348b0 into main Nov 8, 2025
4 checks passed
@mjackson mjackson deleted the session branch November 8, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add session-middleware to fetch-router Add session package

3 participants