Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme: Add Astro example #771

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from
Draft

Readme: Add Astro example #771

wants to merge 1 commit into from

Conversation

tordans
Copy link
Contributor

@tordans tordans commented Nov 18, 2024

I am testing out nuqs with an Astro app and it looks like all works great (*).

This example for the Readme shows a possible way to use it.

The thing that is different for Astro is, that there is no "Root" to place the NuqsAdapter IMO, since each Astro island is independent. Which is why we need to do this semi-elegant wrapper component.

There might be better ways to do this, though.

(*) (!) However, I did not test (yet) how this behaves with multiple islands and NuqsAdapters. This could very well break the setup. Until now I used the recommended nanostore in those cases. See https://docs.astro.build/en/recipes/sharing-state-islands/
However, nanostore remove the nuqs like helper methods at some point. More on this is in nanostores/router#30. My previous workaround was to use a copy of the removed helper, eg. osmberlin/www.osm-verkehrswende.org@3d2e27b#diff-acaaec4d6340f096b1c5dab9c107023b24ec701667fa9c9bb362fdf9e92ce846R55


I will mark this as a draft for now until the (!) is cleared up.

@tordans tordans changed the title Readme: Add Astro example // Support Astro Readme: Add Astro example Nov 18, 2024
Copy link

vercel bot commented Nov 18, 2024

@tordans is attempting to deploy a commit to the 47ng Team on Vercel.

A member of the Team first needs to authorize it.

@franky47
Copy link
Member

franky47 commented Nov 18, 2024

Thanks! Eric Burel also pointed out nanostores for shared Astro state on Bluesky: https://bsky.app/profile/francoisbest.com/post/3lah564mkmd2w

Unlike the other adapters, I'm not actually sure the React adapter would work if two of them were added as siblings (eg: in different islands), as they don't yet have a way to re-render when the URL changes via external means (eg: an explicit call to the history API, or another island doing a setState on a useQueryState). If they were to be loaded in memory multiple times (code-split per island rather than made into a common chunk), the separate event emitters would also not be able to sync the internal states across islands.

Copy link

vercel bot commented Nov 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuqs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 10:01am

@franky47 franky47 added the documentation Improvements or additions to documentation label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants