JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q17900F
  • License MIT

A Next.js hook designed to parse and return query-string params on every render, even on load

Package Exports

  • next-query
  • next-query/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (next-query) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

next-query 🔎

NPM Version Package License NPM Downloads

Blurb

A hook for Next.js which can parse and return a query-string object, even on load.

Installation

npm install next-query
yarn add next-query

Usage

Basic

import useQuery from 'next-query';

function Page() {
  // Returns => { id: string | string[] };
  const { id } = useQuery();
  
  ...
}

Typed

import useQuery from 'next-query';

function Page() {
  // Return Type => { id: string };
  const { id } = useQuery<{ id: string }>();
  
  ...
}

Parsed

import useQuery from 'next-query';

function Page() {
  // Return Type => { id: number };
  const { id } = useQuery({ id: Number });
  
  ...
}

See Supported Parse Types for more

Arrays

import useQuery from 'next-query';

function Page() {
  // Return Type => { ids: number[] };
  const { ids } = useQuery({ ids: [Number] });
  
  ...
}

Complex

import useQuery from 'next-query';

function Page() {
  // Return Type => { id: number, selected: boolean };
  const { ids, selected } = useQuery({ id: Number, selected: Boolean }); 
  
  ...
}

API

Supported Parse Types

String | Boolean | Number