Tauri Fetch
A lightweight utility that automatically uses Tauri's HTTP plugin for network requests when running in a Tauri app environment.
- 🔄 Seamlessly replaces the global fetch API with Tauri's HTTP plugin
- 🌱 No changes needed to your existing fetch calls
- 🔒 Only intercepts requests to HTTP/HTTPS URLs
- ⚛️ Includes a React hook for easy integration
- 🧩 Works with any framework (React, Svelte, Vue, etc.)
First set up the Tauri HTTP Client plugin:
https://v2.tauri.app/plugin/http-client/
``bashpnpm
pnpm add @daveyplate/tauri-fetch
Usage
$3
For React applications, use the provided hook:
`jsx
import { useTauriFetch } from "@daveyplate/tauri-fetch/react";function App() {
// Hook will automatically setup Tauri fetch on component mount
useTauriFetch();
return
My Tauri App;
}
`$3
For Svelte applications, use the core function in your
onMount lifecycle:`svelte
My Tauri App
`$3
Simply import and call the setup function:
`js
import { setupTauriFetch } from '@daveyplate/tauri-fetch';// Call this early in your application lifecycle
setupTauriFetch();
`How it works
This package checks if your app is running in a Tauri environment. If it is, it intercepts all
fetch calls to HTTP/HTTPS URLs and redirects them through Tauri's HTTP plugin. Local requests, like navigation, will still use the original fetch` implementation.MIT