diff --git a/packages/core/useUrlSearchParams/index.ts b/packages/core/useUrlSearchParams/index.ts index 7ff08f1a65f..a859a6a98a1 100644 --- a/packages/core/useUrlSearchParams/index.ts +++ b/packages/core/useUrlSearchParams/index.ts @@ -64,9 +64,9 @@ export function useUrlSearchParams = UrlParams>( const stringified = params.toString() if (mode === 'history') - return `${stringified ? `?${stringified}` : ''}${location.hash || ''}` + return `${stringified ? `?${stringified}` : ''}${window.location.hash || ''}` if (mode === 'hash-params') - return `${location.search || ''}${stringified ? `#${stringified}` : ''}` + return `${window.location.search || ''}${stringified ? `#${stringified}` : ''}` const hash = window.location.hash || '#' const index = hash.indexOf('?') if (index > 0)