Twitch + Netlify Repo Example
This repository is the full working example from Prince's blog post on "Using Twitch to Invoke a Netlify Function".
Prerequisites
- A Netlify account
- A Twitch account
- Node.js installed
Setting it all up
If you want to just get this all setup and just see it working:
-
Deploy this repo to Netlify (e.g. using the Netlify CLI
ntl deploy --prod
) -
Take the link that generates and save it for the Twitch CLI
-
Setup the EventSub subscription through the API or CLI
If you want to do it through the CLI:
twitch api post eventsub/subscriptions --body '{
"type": "stream.online",
"version": "1",
"condition": {
"broadcaster_user_id": "<USE YOUR BROADCASTER ID>"
},
"transport": {
"method": "webhook",
"callback": "<ADD_YOUR_NETLIFY_LINK>/.netlify/functions/log",
"secret": "CHANGE_THIS_SECRET"
}
}'
Note: The secret
is whatever string you'd want it to be. This is a secret you establish with Twitch on this request and whenever you need to verify the signature actually came from Twitch, you'll use this string.
(If you don't have your broadcaster_id use twitch api get users -q login=<YOUR TWITCH HANDKE>
)
And it should be all set!