Catalog npm
Back to packageRELEASE DETAILS

1.0.0

npm

@03gibbss/remix-auth-twitch

A TwitchStrategy for Remix Auth, based on the OAuth2Strategy

authauthenticationremixremix-authstrategytwitch
Published30 May 2022
Direct dependencies25
Transitive dependenciesNot calculated

README

Current package documentation

TwitchStrategy

The Twitch strategy is used to authenticate users against a Twitch account. It extends the OAuth2Strategy.

Supported runtimes

RuntimeHas Support
Node.js✅
Cloudflare✅

Usage

Create an OAuth application

Follow the steps on the Twitch documentation to create a new application and get a client ID and secret.

Install via npm

npm i @03gibbss/remix-auth-twitch

Create the strategy instance

import { TwitchStrategy } from "@03gibbss/remix-auth-twitch";

let twitchStrategy = new TwitchStrategy(
  {
    clientID: "YOUR_CLIENT_ID",
    clientSecret: "YOUR_CLIENT_SECRET",
    callbackURL: "https://example.com/auth/twitch/callback",
  },
  async ({ accessToken, extraParams, profile }) => {
    // Get the user data from your DB or API using the tokens and profile
    const user = await db.user.findUnique({
      where: { twitchId: profile.id },
    });

    if (user) {
      return { id: user.id, displayName: user.displayName };
    }

    const newUser = await db.user.create({
      data: { twitchId: profile.id, displayName: profile.display_name },
    });

    return { id: newUser.id, displayName: newUser.displayName };
  }
);

authenticator.use(twitchStrategy);

Setup your routes

// app/routes/login.tsx
export default function Login() {
  return (
    <Form action="/auth/twitch" method="post">
      <button>Login with Twitch</button>
    </Form>
  );
}
// app/routes/auth/twitch.tsx
import { ActionFunction, LoaderFunction, redirect } from "remix";
import { authenticator } from "~/auth.server";

export let loader: LoaderFunction = () => redirect("/login");

export let action: ActionFunction = ({ request }) => {
  return authenticator.authenticate("twitch", request);
};
// app/routes/auth/twitch/callback.tsx
import { LoaderFunction } from "remix";
import { authenticator } from "~/auth.server";

export let loader: LoaderFunction = ({ request }) => {
  return authenticator.authenticate("twitch", request, {
    successRedirect: "/dashboard",
    failureRedirect: "/login",
  });
};

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 26

Native requirements
25 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
remix-auth
Environment
{
  "local_name": "remix-auth",
  "alias": false,
  "peer_metadata": null
}
^3.0.0runtime
remix-auth-oauth2
Environment
{
  "local_name": "remix-auth-oauth2",
  "alias": false,
  "peer_metadata": null
}
^1.2.2runtime
@babel/core
Environment
{
  "local_name": "@babel/core",
  "alias": false,
  "peer_metadata": null
}
^7.14.2development
@babel/preset-env
Environment
{
  "local_name": "@babel/preset-env",
  "alias": false,
  "peer_metadata": null
}
^7.14.1development
@babel/preset-react
Environment
{
  "local_name": "@babel/preset-react",
  "alias": false,
  "peer_metadata": null
}
^7.13.13development
@babel/preset-typescript
Environment
{
  "local_name": "@babel/preset-typescript",
  "alias": false,
  "peer_metadata": null
}
^7.13.0development
@remix-run/node
Environment
{
  "local_name": "@remix-run/node",
  "alias": false,
  "peer_metadata": null
}
^1.0.3development
@remix-run/react
Environment
{
  "local_name": "@remix-run/react",
  "alias": false,
  "peer_metadata": null
}
^1.1.1development
@remix-run/server-runtime
Environment
{
  "local_name": "@remix-run/server-runtime",
  "alias": false,
  "peer_metadata": null
}
^1.0.0development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^26.0.23development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^4.23.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^4.23.0development
babel-jest
Environment
{
  "local_name": "babel-jest",
  "alias": false,
  "peer_metadata": null
}
^26.6.3development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^7.26.0development
eslint-config-prettier
Environment
{
  "local_name": "eslint-config-prettier",
  "alias": false,
  "peer_metadata": null
}
^8.3.0development
eslint-plugin-jest
Environment
{
  "local_name": "eslint-plugin-jest",
  "alias": false,
  "peer_metadata": null
}
^24.3.6development
eslint-plugin-jest-dom
Environment
{
  "local_name": "eslint-plugin-jest-dom",
  "alias": false,
  "peer_metadata": null
}
^3.9.0development
eslint-plugin-prettier
Environment
{
  "local_name": "eslint-plugin-prettier",
  "alias": false,
  "peer_metadata": null
}
^3.4.0development
eslint-plugin-unicorn
Environment
{
  "local_name": "eslint-plugin-unicorn",
  "alias": false,
  "peer_metadata": null
}
^32.0.1development
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^26.6.3development
jest-fetch-mock
Environment
{
  "local_name": "jest-fetch-mock",
  "alias": false,
  "peer_metadata": null
}
^3.0.3development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.3.2development
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
^17.0.2development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
^10.8.0development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.3.5development
@remix-run/server-runtime
Environment
{
  "local_name": "@remix-run/server-runtime",
  "alias": false,
  "peer_metadata": null
}
^1.0.0peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-GvHJjaNL/foUJN624wQ2aCClN51E9vAWiDTGHDpl5fjnx5DqLVqvYOeiFreozSVXBL5oKnNxcD7AYoLp5b1qHA==",
  "shasum": "dbe9c86d3c05ceb7df2df59016cd6b4f097a6860",
  "tarball": "https://registry.npmjs.org/@03gibbss/remix-auth-twitch/-/remix-auth-twitch-1.0.0.tgz",
  "fileCount": 5,
  "unpackedSize": 9681,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQCQDdlL9DbcPzWg6z3mgOSPpV4ZEwAuuDYHamHk7lKGmwIgHcCQ0+FjnK3uOs6EbV+d99kKaU82PW2KPFGVWrT2c9k="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJilTdtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrJKg//TniSqjX2rnhrvmV97aBDQ1DPRb+hRRcsWlEGjNsAD7jybtaz\r\nHB+lnuDw64do/PLIoJt7jSA3cCMrdP180p2wXdIqO0tajcVPXwaqwRUSVMby\r\no+BIe0zGH0RndWxhiC+Y1IBMFvh82d1LXK7k/fDHN/gCbyny1Frjw6F3sU3S\r\nXJgwkp5K3UB5oMyzA6J+zQcZmK7VP6KL1NV4OCqwQkiNRfz5+BWm60rDYFM5\r\nekb9DF6JGQ4MG/spBSfFxfkYMSCNWDS944YtPY6YQgcz89LvPimC+C0p6fj1\r\nrsw3EqowA8SQ2YZXFgvkZEL9FkCaBCDTvbkz7F4TxWStNPKe9XVhAXNZTYcg\r\nfCCmQ8wFJUn2uIDge0/6y71qYtDGCgniL5ZEVOIheiBnxish25iEzKQgDuJR\r\nb9sh7r7Vy3Ccppnr3dsTYTsbLatddJCpoX+v+u9iPASjeHdMR9p257ST6gcy\r\nZYc/4kLv8Qg2m7ZHQ9kZ6vz+Z5+O1SIEJ/EyRMNzAVetdh7fZcjtb1+YNjXQ\r\nPE/MRrxzlNaZXvZVPXvvLkb/t8MfGOt+riFXXtBxyk7wr8FZUBlhMkGkfSZU\r\ny7jsuUZW3d2rCovAXqabpDe59efLqWK82gRItrq/C+iT7BS5TwpDWBBuhxVw\r\n/vy5EruJY+I0lLQGN4O6Xk6F1bd+ZuU1/tI=\r\n=TnfQ\r\n-----END PGP SIGNATURE-----\r\n"
}

Repository

PENDING
03gibbss/remix-auth-twitch

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:00 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:c854da50f29ef8f4f30cd6c9d58f77541c775b14f0dfe6ea36f6174716990cb2

Other collected versions

1.0.130 MayView all collected versions →