Registry / crm / fetch-salesforce

fetch-salesforce

JSON →
library2.0.1jsnpmunverified

A client for the Salesforce REST API using the Fetch API. Current stable version is 2.0.1. The library is maintained and designed for React Native but works in any environment supporting fetch. It provides a simple interface for CRUD operations, queries, and authentication. Version 2.0 introduces breaking changes, including requiring fetch to be defined globally. Differentiators: lightweight, no heavy dependencies, TypeScript-first with full typings.

crm
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The package is ESM-only; CommonJS require will fail.

import { FetchSalesforce } from 'fetch-salesforce'

This is a named export, not a default export.

import { SalesforceOptions } from 'fetch-salesforce'

fetchSObject is a property of FetchSalesforce instance, not a standalone import.

fetchSalesforce.fetchSObject.insert('Account', { Name: 'My Account' })

fetchQuery is accessed via the FetchSalesforce instance.

fetchSalesforce.fetchQuery.query('SELECT ID FROM Account LIMIT 10')

Shows how to instantiate the client with required options and run a simple SOQL query.

import { SalesforceOptions, FetchSalesforce } from 'fetch-salesforce'; const options: SalesforceOptions = { clientID: process.env.SF_CLIENT_ID ?? '', authorizationServiceURL: process.env.SF_AUTH_URL ?? 'https://login.salesforce.com/services/oauth2/authorize', tokenServiceURL: process.env.SF_TOKEN_URL ?? 'https://login.salesforce.com/services/oauth2/token', redirectUri: process.env.SF_REDIRECT_URI ?? 'https://localhost:3000/callback', apiVersion: 58.0, logLevel: 'INFO', }; const sf = new FetchSalesforce(options); async function run() { const result = await sf.fetchQuery.query('SELECT Id, Name FROM Account LIMIT 2'); console.log('Query result:', JSON.stringify(result, null, 2)); } run().catch(console.error);
Debug
Known footguns
breakingVersion 2.0 requires fetch to be globally defined; it no longer bundles a fetch polyfill.
breakingAll exports are now named; there is no default export. CommonJS require('fetch-salesforce') will fail.
deprecatedThe logLevel option with values 'DEBUG', 'INFO', 'WARN', 'ERROR' may be removed in future versions. Use numeric log levels instead.
gotchaThe apiVersion option accepts a number (e.g., 39.0) but may be misinterpreted if passed as a string (e.g., '39.0').
gotchaWhen using OAuth, the redirectUri must match the one configured in your Salesforce connected app exactly, including trailing slashes.
gotchaThe library does not handle token refresh automatically; you must implement refresh logic in your application.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
23 hits · last 30 days
gptbot
3
amazonbot
3
bytedance
2
ahrefsbot
1
Resources