Skip to content

valifetch/auth ​

Built-in beforeRequest hook factories for common authentication patterns.

Import from the valifetch/auth subpath so the auth code is tree-shaken out of bundles that don't use it.

Example ​

ts
import valifetch from 'valifetch';
import { bearerAuth, basicAuth, jwtRefresh } from 'valifetch/auth';

const api = valifetch.create({
  hooks: {
    beforeRequest: [bearerAuth(() => localStorage.getItem('token'))],
  },
});

Type Aliases ​

Functions ​

Released under the MIT License. Built with Claude Code.