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

@shopify/react-csrf

Package Overview
Dependencies
Maintainers
24
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/react-csrf

Share CSRF tokens throughout a React application

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
increased by17.02%
Maintainers
24
Weekly downloads
 
Created
Source

@shopify/react-csrf

Build Status Build Status License: MIT npm version npm bundle size (minified + gzip)

Share CSRF tokens throughout a React application.

Installation

yarn add @shopify/react-csrf

Usage

Setup the Provider around all of the application that need to access csrf token.

// App.tsx
import * as React from 'react';
import {CsrfTokenContext} from '@shopify/react-csrf';

function App({token}: {token?: string}) {
  return (
    <CsrfTokenContext.Provider value={token}>
      {/* rest of the app */}
    </CsrfTokenContext.Provider>
  );
}

Access csrf token using useCsrfToken hook:

import React from 'react';
import {useCsrfToken} from '@shopify/react-csrf';

export default function MyToken() {
  const csrfToken = useCsrfToken();
  return <p>My CSRF Token is: {csrfToken}</p>;
}

FAQs

Package last updated on 10 Jun 2024

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