@urbicon-ui/sveltekit-utils 6.43.2 → 6.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,6 +81,12 @@ export declare function createUrlParam<T>(_key: string, options: UrlParamOptions
81
81
  * initial render reflects the incoming URL. The setter calls the client-only
82
82
  * `goto` and is meant to run from event handlers/effects — never during SSR.
83
83
  *
84
+ * Prerender-safe: SvelteKit forbids reading `url.searchParams` while
85
+ * prerendering (the emitted HTML must not depend on a query string that will
86
+ * not exist at request time). During `building` the getter therefore yields
87
+ * {@link UrlParamOptions.initial} — "absent" is the truth for that render;
88
+ * after hydration the client re-reads the real URL reactively.
89
+ *
84
90
  * A **getter**, not a store, is returned on purpose: call it lazily inside
85
91
  * `$derived`/`$effect` and the read is tracked there.
86
92
  *
@@ -1,3 +1,4 @@
1
+ import { building } from '$app/environment';
1
2
  import { goto } from '$app/navigation';
2
3
  import { page } from '$app/state';
3
4
  import { applyTableQueryToSearchParams, searchParamsToTableQuery } from './table-query';
@@ -99,6 +100,12 @@ export function createUrlParam(_key, options) {
99
100
  * initial render reflects the incoming URL. The setter calls the client-only
100
101
  * `goto` and is meant to run from event handlers/effects — never during SSR.
101
102
  *
103
+ * Prerender-safe: SvelteKit forbids reading `url.searchParams` while
104
+ * prerendering (the emitted HTML must not depend on a query string that will
105
+ * not exist at request time). During `building` the getter therefore yields
106
+ * {@link UrlParamOptions.initial} — "absent" is the truth for that render;
107
+ * after hydration the client re-reads the real URL reactively.
108
+ *
102
109
  * A **getter**, not a store, is returned on purpose: call it lazily inside
103
110
  * `$derived`/`$effect` and the read is tracked there.
104
111
  *
@@ -124,7 +131,7 @@ export function createUrlParam(_key, options) {
124
131
  */
125
132
  export function useUrlParam(key, options) {
126
133
  const { get, set } = createUrlParam(key, options);
127
- const getBound = () => get(page.url.searchParams);
134
+ const getBound = building ? () => options.initial : () => get(page.url.searchParams);
128
135
  return [getBound, set];
129
136
  }
130
137
  /**
@@ -219,7 +226,9 @@ export function useUrlArrayParam(key, opts) {
219
226
  * (write a query back to the URL).
220
227
  */
221
228
  export function createTableQueryUrlSync(options = {}) {
222
- const initialQuery = searchParamsToTableQuery(page.url.searchParams, options);
229
+ // Same prerender rule as `useUrlParam`: no query string exists while
230
+ // building, so the seed parses from empty params instead of throwing.
231
+ const initialQuery = searchParamsToTableQuery(building ? new URLSearchParams() : page.url.searchParams, options);
223
232
  function syncQuery(query) {
224
233
  const next = applyTableQueryToSearchParams(page.url.searchParams, query, options);
225
234
  const qs = next.toString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urbicon-ui/sveltekit-utils",
3
- "version": "6.43.2",
3
+ "version": "6.45.0",
4
4
  "description": "SvelteKit helper utilities — createCronRunner, streamSse, and URL-state runes",
5
5
  "license": "MIT",
6
6
  "repository": {