Neutron Polarization Manipulator

    gatsby-query-params

    1.2.1 • Public • Published

    gatsby-query-params

    Get query params of the current URL in Gatsby

    NPM JavaScript Style Guide

    Install

    npm add gatsby-query-params

    Function Signature

    1. getSearchParams - Return query parameters as an object.
    import { getSearchParams } from "gatsby-query-params";
     
    const searchParams = getSearchParams();
    1. useQueryParam - Return query parameter for a specific key. If it doesn't exist, returns a set default value ( default null ).
    import { useQueryParam } from "gatsby-query-params";
     
    const value = useQueryParam(key, defaultValue);

    Usage

    import React, {useState, useEffect} from 'react'
    import { useQueryParam, getSearchParams } from "gatsby-query-params";
     
    function App() {
      
      const name = useQueryParam("name", "Akash"); // key, defaultValue
      console.log(name); // log query param
      console.log(getSearchParams()); // Log all parameters
     
      return (
        <div>
          Hello
        </div>
      )
    }
     
    export default App

    License

    GPLV3 © akash-joshi

    Install

    npm i gatsby-query-params

    DownloadsWeekly Downloads

    1,322

    Version

    1.2.1

    License

    GPLV3

    Unpacked Size

    117 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar