Skip to content

feat(memory-location): add initial location state support#564

Merged
molefrog merged 1 commit into
molefrog:v3from
astakhovaskold:feature/memory-location-state
May 17, 2026
Merged

feat(memory-location): add initial location state support#564
molefrog merged 1 commit into
molefrog:v3from
astakhovaskold:feature/memory-location-state

Conversation

@astakhovaskold
Copy link
Copy Markdown
Contributor

Summary

Adds initial state support to memoryLocation, so tests and custom in-memory routing setups can seed the current location state and read it back from the returned object.

This change keeps the API small:

  • memoryLocation({ path, state }) now accepts an initial state
  • navigate(..., { state }) updates that state
  • the current value is exposed as memory.state

The value is intentionally exposed on the memoryLocation(...) result object rather than as a destructured snapshot, so it always reflects the latest navigation state.

Changes

  • added state option to memoryLocation
  • stored and updated current in-memory location state alongside path/search
  • made reset() restore the initial state as well as the initial path
  • updated TypeScript declarations for both wouter and wouter-preact
  • added runtime and type coverage for the new API

Testing

  • bun test packages/wouter/test/memory-location.test.ts
  • bun test-types

Closes #492

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Copy Markdown
Owner

@molefrog molefrog left a comment

Choose a reason for hiding this comment

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

Two small inline notes on navigate and reset.


Generated by Claude Code

Comment thread packages/wouter/src/memory-location.js Outdated
Comment thread packages/wouter/src/memory-location.js
@astakhovaskold astakhovaskold force-pushed the feature/memory-location-state branch from d0fc622 to 86c3019 Compare May 17, 2026 20:57
@molefrog molefrog merged commit 9d8a81a into molefrog:v3 May 17, 2026
3 checks passed
@molefrog
Copy link
Copy Markdown
Owner

Thanks, planning this for the next release

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.

Support passing down state in memoryLocation.

2 participants