Svelte Quickstart
ExpressCSV is a TypeScript-first CSV importer that runs in your users' browser, so you can ship polished, private imports without building the whole flow yourself.
Use this pre-built prompt to get started faster with Svelte.
Alternatively, follow these steps to manually add ExpressCSV to a Svelte app and relay imports to your existing backend.
-
Install the SDK
-
On your backend: create a session endpoint 🔒
Create a small backend route that exchanges your ExpressCSV secret key for a short-lived auth token.
For example, in a Hono backend:
-
On your frontend: define your import schema
Describe the columns you want to accept:
-
On your frontend: open the importer
The example below shows how to open the importer from the client and send validated rows in chunks.
-
Render the button in your app
Saving imported rows
How you save imported rows on the backend is up to you. A recommended pattern:
- Add an import chunk staging table with
sessionId,deliveryId, andchunkIndexcolumns plus a JSON column for the chunk payload (e.g.records), separate from your business tables:
- On each chunk POST, upsert a staging row keyed by
(sessionId, deliveryId, chunkIndex)from the request body and storerecordsin the JSON column. Retries update the same row instead of inserting a duplicate:
- Wait for the last chunk before writing to your business tables:
onError: delete staged chunks for thedeliveryIdwhen delivery fails partway through.onCancel: delete staged chunks for thesessionIdwhen the user cancels.
See Delivery for the import chunk staging table, writing the uploaded records to your target table(s) from staged JSON, and idempotent chunk writes.
What's Next
- Auth tokens: keep your secret key on the backend and return fresh importer tokens
- Delivery: store chunk JSON, write uploaded records to target tables when the ledger is complete, clean up aborted sessions
- Types: define field types, validation rules, and inferred row types
- Column matching: map messy CSV headers to your schema fields
- Prompted edits: let users clean imported values with prompts