Express CSV Logo

SDK Reference

@expresscsv/sdk is centered around the CSVImporter class. You configure it once, then call open() when you want to start an import.

new CSVImporter(options)

Common constructor options:

OptionDescription
schemaSchema definition created with x.row()
publishableKeyYour publishable key from the dashboard
importIdentifierUnique identifier for this import type
titleTitle shown in the widget header
preloadPreload widget in a hidden iframe for instant display
themeTheme variable overrides
colorMode'light', 'dark', or 'system'
customCSSCustom CSS injected into the widget
fontsCustom font sources
stepDisplayStep indicator style
previewSchemaBeforeUploadShow expected columns before upload
templateDownloadOffer downloadable template files
saveSessionPersist session for resuming interrupted imports
localeLocale string overrides
disableStatusStepSkip the success/error status screen

open(options)

You must provide at least one of onData or webhook.

OptionDescription
onDataCallback for each chunk. Call next() to receive the next chunk.
webhookWebhook endpoint for server-side delivery
chunkSizeRecords per chunk (default: 1000)
onCompleteCalled when all chunks have been processed
onCancelCalled when the user cancels the import
onErrorCalled when an error occurs
onWidgetOpenCalled when the widget opens
onWidgetCloseCalled when the widget closes
onStepChangeCalled when the wizard step changes

Lifecycle And Status Methods

MethodDescription
close(reason?)Closes the widget, optionally with a close reason
restart(newOptions?)Resets and reopens the widget for a new import
getState()Returns the current widget state
getIsReady()Returns true when the widget is initialized and ready to open
getIsOpen()Returns true while the widget is open
getConnectionStatus()Returns the current iframe connection status
getCanRestart()Returns true when the widget can be restarted
getLastError()Returns the most recent error, if any
getStatus()Returns a snapshot of importer status helpers
getVersion()Returns the SDK version

Example

const importer = new CSVImporter({
  schema,
  publishableKey: "your-publishable-key",
  importIdentifier: "user-import",
});

console.log(importer.getStatus());

await importer.close("user_close");

When To Use TypeScript Vs React

Use the base SDK when:

  • your app is not built with React
  • you want an imperative importer instance
  • you need direct lifecycle and status methods

If you want hook-based state and component lifecycle integration, use the React API instead.