• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
stevekrouse

stevekrouse

nuqs-demo

Public
Like
nuqs-demo
Home
Code
4
App.tsx
README.md
index.html
H
main.tsx
Branches
1
Pull requests
Remixes
1
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
6/25/2025
README.md

Minimal nuqs Demo

This val was created to repro the bug getting started with nuqs.

Github issue: https://github.com/47ng/nuqs/issues/1024#issuecomment-3001766923

The issue

ValTown uses esm.sh to import third party libraries, which does bundle them by default. Since we have two exports (one for the nuqs hooks and one for the React adapter), they are both bundled separately, causing the Context reference that powers adapters to be duplicated, and therefore not being able to connect (causing the NUQS-404 and NUQS-303 errors).

The solution

We need to tell esm.sh not to bundle nuqs, as it's already ESM, so it can resolve the same Context reference for the adapters to work. This is done by passing a bundle=false search param (got to love URL state 😍) to all nuqs imports:

import { NuqsAdapter } from "https://esm.sh/nuqs/adapters/react?deps=react@18.2.0,react-dom@18.2.0&bundle=false";
import { useQueryState } from "https://esm.sh/nuqs?deps=react@18.2.0,react-dom@18.2.0&bundle=false";
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.