Getting Started

Dexie.js can be consumed as a module. But let’s skip that for now and just show the simplest possible setup. You will just need a text editor and a web browser.

Quick Start

  1. Copy this code to and save as ‘whatever.html’
<!doctype html>
      <!-- Include Dexie -->
      <script src=""></script>

          // Define your database
          var db = new Dexie("friend_database");
              friends: 'name,shoeSize'

          // Put some data into it
          db.friends.put({name: "Nicolas", shoeSize: 8}).then (function(){
              // Then when data is stored, read from it
              return db.friends.get('Nicolas');
          }).then(function (friend) {
              // Display the result
              alert ("Nicolas has shoe size " + friend.shoeSize);
          }).catch(function(error) {
             // Finally don't forget to catch any error
             // that could have happened anywhere in the
             // code blocks above.
             alert ("Ooops: " + error);
  1. Open the file in Chrome, Opera or Firefox. If you need to test on IE, Edge or Safari, make sure to serve the page over http or https

  2. You should see an alert box pops up saying Nicolas has shoe size 8.

  3. Play with this file. Change some code and see what happens.

Next steps

Consuming dexie as a module




Migrating existing DB to Dexie


Back to Tutorial

Table of Contents