Getting Started with JavaScript for Web Development: Lesson 20 of 23

Storing to LocalStorage

Up Next

Deleting Bookmarks

Autoplaying in 7 seconds!

Cancel

<

Table of Contents

    a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage">https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage

    LocalStorage allows us to save information to the browser itself. This let's us persist data for our users without having to make a trip to an actual database.

    Using LocalStorage

    // save to localStorage
    localStorage.setItem('username', 'chris');
    
    // get data from localStorage
    localStorage.getItem('username');

    Chris Sevilleja

    176 posts

    Founder of Scotch.io. Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.