Add a complete CSV and Excel importer to your Next.js app, with column mapping, real-time validation, and API integration built in.

Installation

Install the following package

1npm install @importok/javascript

Note: The trial version is available on NPM. When you upgrade, you'll get access to our private packages with full features. No code changes required.

Your first importer

Create a basic contact importer:

1import ImportOK from './node_modules/@importok/javascript/importok.js';
2window.onload = function () {
3 const fields = {
4 first_name: { label: 'First Name' },
5 last_name: { label: 'Last Name' },
6 email: { label: 'Email' },
7 phone: { label: 'Phone' },
8 country: { label: 'Country' }
9 };
10 
11 ImportOK.add(
12 document.getElementById('import-wizard'),
13 {
14 title: 'Import Contacts',
15 fields: fields,
16 }
17 );
18}

That's it. Users can now upload CSV or Excel files and map columns to your fields.

Make it production-ready

Add data transformations

Clean up data before validation using transformers:

1const fields = {
2 first_name: {
3 label: 'First Name',
4 transformers: 'trim|capitalize' // Built-in transformers
5 },
6 last_name: {
7 label: 'Last Name',
8 transformers: 'trim|capitalize'
9 },
10 email: {
11 label: 'Email',
12 transformers: 'trim'
13 }
14};

See all built-in transformers →

Add validation rules

Catch errors before they reach your API using validators:

1const fields = {
2 first_name: {
3 label: 'First Name',
4 transformers: 'trim|capitalize'
5 },
6 last_name: {
7 label: 'Last Name',
8 transformers: 'trim|capitalize',
9 validators: 'required' // Built-in validators
10 },
11 email: {
12 label: 'Email',
13 transformers: 'trim',
14 validators: 'email|required'
15 }
16};

See all built-in validators →

Connect to your API

Send validated data to your backend:

1import ImportOK from './node_modules/@importok/javascript/importok.js';
2window.onload = function () {
3 const fields = { /* ... */ };
4 
5 const handleImport = async function (records, meta) {
6 const response = await fetch('/api/contacts/imports', {
7 method: 'POST',
8 headers: { 'Content-Type': 'application/json' },
9 body: JSON.stringify(records)
10 });
11 
12 return response;
13 };
14 
15 ImportOK.add(
16 document.getElementById('import-wizard'),
17 {
18 title: 'Import Contacts',
19 fields: fields,
20 onImportReady: handleImport
21 }
22 );
23}

Complete example

Here's everything together:

1import ImportOK from './node_modules/@importok/javascript/importok.js';
2window.onload = function () {
3 const fields = {
4 first_name: {
5 label: 'First Name',
6 transformers: 'trim|capitalize'
7 },
8 last_name: {
9 label: 'Last Name',
10 transformers: 'trim|capitalize',
11 validators: 'required'
12 },
13 email: {
14 label: 'Email',
15 transformers: 'trim',
16 validators: 'email|required'
17 }
18 };
19 
20 const handleImport = async function (records, meta) {
21 const response = await fetch('/api/contacts/imports', {
22 method: 'POST',
23 headers: { 'Content-Type': 'application/json' },
24 body: JSON.stringify(records)
25 });
26 
27 return response;
28 };
29 
30 ImportOK.add(
31 document.getElementById('import-wizard'),
32 {
33 title: 'Import Contacts',
34 fields: fields,
35 onImportReady: handleImport
36 }
37 );
38}

Next steps

Now that you have a working importer, explore advanced features:

Try it live

Experiment with a complete example in StackBlitz:

Open in StackBlitz →

Trial limitations

The free trial includes:

  • ✅ Full UI and mapping features
  • ✅ Built-in validators and transformers
  • ⚠️ 20 records per import (unlimited on paid plans)
  • ⚠️ Up to 2 custom validators (unlimited on paid plans)
  • ⚠️ Up to 2 custom transformers (unlimited on paid plans)
  • ⚠️ Up to 2 data providers (unlimited on paid plans)

When you're ready, upgrade to unlock full features with access to our private packages.

Start typing to search documentation and articles...

⌘K or Ctrl+K to open search

No results found for ""

Try different keywords or check your spelling.

Use ↑ ↓ arrow keys to navigate and Enter to select