New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@better-typed/react-query-params-hooks

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@better-typed/react-query-params-hooks

React query params hooks

  • 0.9.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
2
Weekly downloads
 
Created
Source

React Query Params Hooks

NPM npm bundle size npm type definitions NPM npm GitHub stars

Easy query params handling for React

Features

  • :rocket: Simple, fast and light
  • :factory: Set, Update, Delete, Clear
  • 🪗 Provider for global configs and any environment

Install

npm install --save @better-typed/react-query-params-hooks

or

yarn add @better-typed/react-query-params-hooks

Usage

import React from "react";
import { useQueryParams } from "@better-typed/react-query-params-hooks";

const MyComponent: React.FC = () => {
  const {queryParams, queryString, stringify, setQueryParam, setQueryParams, updateQueryParams, deleteQueryParam, clearQueryParams } = useQueryParams()

  return (
    // ...
  )
}

Connect to your router

First we have to wrap our App with QueryParamsProvider and provide setQueryParams and getQueryString methods. Below we have an example of usage with React Router v6.

import React from "react";
import { useQueryParams } from "@better-typed/react-query-params-hooks";

const App: React.FC = ({ children }) => {
  const location = useLocation();
  const [, setSearchParams] = useSearchParams();

  return (
    <QueryParamsProvider
      getQueryString={() => location.search}
      setQueryParams={(search) => setSearchParams({ search }, { replace: true })}
    >
      {children}
    </QueryParamsProvider>
  );
};

Keywords

FAQs

Package last updated on 30 Jul 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc