# elementor/3.8.0-beta1/app/assets/js/hooks/use-query-params.js

Elementor Website Builder – more than just a page builder, version 3.8.0-beta1. 25 lines.

- Page: https://pluginprobe.com/plugins/elementor/3.8.0-beta1/code/app/assets/js/hooks/use-query-params.js
- Raw: https://pluginprobe.com/plugins/elementor/3.8.0-beta1/raw/app/assets/js/hooks/use-query-params.js
- Modified: 2022-09-19T16:26:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/elementor/3.8.0-beta1/code/app/assets/js/hooks/use-query-params.js#L10-L20`.

```javascript
export default function useQueryParams() {
	const urlSearchParams = new URLSearchParams( window.location.search ),
		urlParams = Object.fromEntries( urlSearchParams.entries() ),
		hashValue = location.hash.match( /\?(.+)/ )?.[ 1 ],
		hashParams = {};

	if ( hashValue ) {
		hashValue.split( '&' ).forEach( ( pair ) => {
			const [ key, value ] = pair.split( '=' );

			hashParams[ key ] = value;
		} );
	}

	// Merging the URL params with the hash params.
	const queryParams = {
		...urlParams,
		...hashParams,
	};

	return {
		getAll: () => queryParams,
	};
}

```
