Skip to content

Instantly share code, notes, and snippets.

@ryochin
Created October 15, 2023 02:26
Show Gist options
  • Save ryochin/b15deec1caabe14e5f978f2bde792cc0 to your computer and use it in GitHub Desktop.
Save ryochin/b15deec1caabe14e5f978f2bde792cc0 to your computer and use it in GitHub Desktop.
Rails: CSRF token on React
import React from 'react'
import { csrfToken } from '@rails/ujs'
export const AuthenticityToken = (): React.ReactElement =>
<input type="hidden" name="authenticity_token" value={csrfToken() ?? ''} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment