Bun and Deno usage
Use case
Use parcely in Bun or Deno applications.
Bun
import { createClient } from '@parcely/core'
const http = createClient({
baseURL: 'https://api.example.com',
timeout: 5000,
})
const { data } = await http.get('/users')
console.log(data)
No special configuration needed. Bun provides globalThis.fetch natively.
Install with:
bun add @parcely/core
Deno
import { createClient } from '@parcely/core'
const http = createClient({
baseURL: 'https://api.example.com',
timeout: 5000,
})
const { data } = await http.get('/users')
console.log(data)
Deno supports npm specifiers:
import { createClient } from 'npm:@parcely/core'
Or add to deno.json:
{
"imports": {
"@parcely/core": "npm:@parcely/core"
}
}
Axios equivalent
The usage pattern is identical to axios in both runtimes. The only difference is the import.
Notes and gotchas
- Both Bun and Deno provide
globalThis.fetchandAbortSignal.anynatively. - The
tlsoption is Node-specific (it usesundiciunder the hood). In Bun and Deno, TLS configuration should be done via runtime-specific mechanisms. - parcely's zero-dep design means there are no compatibility issues with alternative runtimes.