Use/Get URL Query Params

    0

    2

    react-router-dom
    Strong Snippets

    Useful way to get all the query parameters in the URL.

    Can easily be moved into a reusable hook, if you want to use repeatedly.

    Library: react

    Shortcut: get.react-router.url-params

    import { useMemo } from 'react';
    import { useLocation } from 'react-router-dom';
    
    const { search } = useLocation();
    const query = useMemo(() => new URLSearchParams(search), [search]);
    const name = query.get("name")
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.