/capacitor-stream-fetch

A capacitor plugin provides `fetch` with stream support

Primary LanguageKotlin

capacitor-stream-fetch

Fetch with stream support.

Use cases: AI chat completion, SSE, and other uses that require streaming response and CORS.

  • Support Capacitor v7.

  • Only support android.

  • Written in kotlin, so you need to configure kotlin for your project before using it.

Install

npm install capacitor-stream-fetch
npx cap sync

Usage

import { fetch } from 'capacitor-stream-fetch'
// Use it like native fetch

API

streamFetch(...)

streamFetch(options: { url: string; method: string; headers: Record<string, string>; body?: string; }) => any

Execute a HTTP request with streaming response

Param Type Description
options { url: string; method: string; headers: any; body?: string; } The request options

Returns: any


addListener(string, ...)

addListener(eventName: string, listenerFunc: (event: any) => void) => any

Add a listener for a specific event

Param Type Description
eventName string Name of the event to listen for
listenerFunc (event: any) => void Callback function to be called when the event fires

Returns: any


removeAllListeners()

removeAllListeners() => any

Remove all listeners for this plugin

Returns: any


Interfaces

StreamResponse

Prop Type
requestId number
status number
statusText string
headers Record<string, string>

PluginListenerHandle

Prop Type
remove () => any