trpc-refresh-token-link
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

TRPC Refresh Token Link

A link for TRPC that refreshes the token when it expires.

Usage

Install the package with your package manager of choice.

npm install trpc-refresh-token-link

Then use it in your code.

import { refreshTokenLink } from "trpc-refresh-token-link";
import { createTRPCClient } from "@trpc/client";

const api = createTRPCClient({
  links: [
    /* other links */
    refreshTokenLink({
      /* options */
    }),
  ],
});

Options

The refreshTokenLink function accepts an object with the following properties:

  • shouldRefresh: (op: Operation) => boolean: A function that determines whether the token should be refreshed for a given operation. To call the refresh token function, return true.
  • refreshToken: (op: Operation) => Promise<void>: A function that refreshes the token and saves it to the client.

/trpc-refresh-token-link/

    Package Sidebar

    Install

    npm i trpc-refresh-token-link

    Weekly Downloads

    0

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    3.49 kB

    Total Files

    4

    Last publish

    Collaborators

    • mkuchak