New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

smart-query-string

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smart-query-string

A lightweight TypeScript utility for parsing and manipulating query strings — no dependencies.

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

Smart Query String

License: MIT npm version TypeScript

A lightweight, zero-dependency TypeScript utility for parsing and manipulating URL query strings. This package provides a simple and type-safe API for working with URL query parameters in both browser and Node.js environments.

Features

  • 🌐 First-class browser support with direct URL manipulation
  • 🔍 Parse query strings into JavaScript objects
  • 📝 Stringify objects into query strings
  • 🔄 Support for arrays and nested objects
  • 🛠️ Built-in TypeScript support
  • 🚫 Zero dependencies
  • 📦 Small bundle size

Installation

Using npm

npm install smart-query-string

Using Yarn

yarn add smart-query-string

Using pnpm

pnpm add smart-query-string

Framework Agnostic This package is designed to work seamlessly with any JavaScript framework including React, Vue, Angular, Svelte, and more. It has no framework dependencies and can be used in any JavaScript or TypeScript project.

Browser Usage

Get Current Query Parameters

import {queryString} from 'smart-query-string';

// Get all current URL query parameters as an object
const currentParams = queryString.get();
// If URL is https://example.com?page=1&sort=name
// Returns: { page: '1', sort: 'name' }

Set Query Parameters

import {queryString} from 'smart-query-string';

// Set query parameters (replaces all existing ones)
queryString.set({page: 2, sort: 'name'});
// Updates URL to: https://example.com?page=2&sort=name

Update Specific Parameters

import {queryString} from 'smart-query-string';

// Update specific parameters while preserving others
queryString.update({page: 3});
// If current URL is https://example.com?page=2&sort=name
// Updates to: https://example.com?page=3&sort=name

Remove All Query Parameters

import {queryString} from 'smart-query-string';

// Remove all query parameters from the URL
queryString.remove();
// Updates URL to: https://example.com

Remove Specific Parameters

import {queryString} from 'smart-query-string';

// Remove specific query parameters
queryString.removeKeys(['sort', 'filter']);
// If current URL is https://example.com?page=1&sort=name&filter=active
// Updates to: https://example.com?page=1

General Usage

Parsing Query Strings

import {queryString} from 'smart-query-string';

// Parse a query string
const params = queryString.parse('foo=bar&baz=qux');
// Returns: { foo: 'bar', baz: 'qux' }

// Parse URL with query string
const {url, query} = queryString.parseUrl('https://example.com?foo=bar');
// url: 'https://example.com'
// query: { foo: 'bar' }

Stringifying Objects

import {queryString} from 'smart-query-string';

// Stringify an object
const query = queryString.stringify({foo: 'bar', baz: 'qux'});
// Returns: 'foo=bar&baz=qux'

// Stringify with URL
const url = queryString.stringifyUrl({
  url: 'https://example.com',
  query: {foo: 'bar'}
});
// Returns: 'https://example.com?foo=bar'

TypeScript Support

This package is written in TypeScript and includes type definitions out of the box.

License

MIT © Mohamed Zaki

Keywords

query-string

FAQs

Package last updated on 26 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts