Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-query-params

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-query-params

A small wrapper for `use-query-params` in Next.js apps.

  • 1.0.0-alpha.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30K
increased by72.75%
Maintainers
1
Weekly downloads
 
Created
Source

next-query-params

Stable release

A small wrapper for use-query-params in Next.js apps.

Installation

npm install next-query-params
// _app.js
import {NextQueryParamProvider} from 'next-query-params';

export default function App({ Component, pageProps }) {
  return (
    <NextQueryParamProvider>
      <Component {...pageProps} />
    </NextQueryParamProvider>
  );
}

Usage

Please refer to the usage of use-query-params. This library only configures the provider for usage with Next.js and additionally re-exports all modules from use-query-params for convenience. Note that use-query-params and query-string is bundled in this library to support IE11.

import { useQueryParam, StringParam, withDefault } from 'next-query-params';

export default function IndexPage() {
  const [name, setName] = useQueryParam('name', withDefault(StringParam, ''));

  function onNameInputChange(event) {
    setName(event.target.value);
  }

  return (
    <p>My name is <input value={name} onChange={onNameInputChange} /></p>
  );
}

// Note that if query parameters affect the server-rendered HTML of the page,
// you should define this function. Statically generated pages only have
// access to query parameters on the client side.
export function getServerSideProps() {
  return {props: {}};
}

Credits

This library is just a small wrapper around use-query-params by Peter Beshai and uses the code that was collaboratively created in use-query-params#13. I mostly moved the code to a reusable library.

FAQs

Package last updated on 31 Aug 2021

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