npm i gdrive-simple



An intuitive and object-oriented wrapper on the Google Drive API. Exposes File and Folder objects which have Promise-based asynchronous functions. Also includes a simple utility for managing signed-in state.

Check out the source code here.

Example usage

import gds from "gdrive-simple";

    clientId: "YOUR CLIENT ID",
    scopes: [
        // Use this scope if you want access to your private app data:
        // This one lets you access files you created in the user's
        // Drive (i.e. not in your app's data folder):
        // This one gives you full access (e.g. to files you didn't
        // create):
        // For all scopes go here:
}).then(() => {
    // The listener given here will be called promptly with the
    // current signed-in state, and again whenever that state changes.

function handleSignedInChange(isSignedIn) {
    if (!isSignedIn) {
        // Show some "Sign in button", call gds.signIn() when that
        // button is clicked
        document.getElementById("signIn").onclick = gds.signIn;
    } else {
        // Do whatever you want! Examples:

        // Get the user's Drive root:
        const root = gds.getRootFolder();
        // Get your app's private App Data folder:
        const appdata = gds.getAppDataFolder();

        // List files in a folder:
        root.listFiles().then(files => {
            console.log("Files in the user's Drive:", files);

        // Get a file by name (creating it if it doesn't exist), and
        // write some JSON to it:
            .then(file => file.write( {thisIsSome:"json"} ))
            .then(() => console.log("myfile.json succesfully written."));

        // Get a subdirectory, then get a file inside it:
            .then(folder => folder.getFile("myfileinmyfolder.json"))
            .then(file =>
            .then(contents => console.log("Contents:", contents));


gdrive-simple is licensed under the MIT License. However, Google's JavaScript client library, which this library depends upon, is licensed under an Apache License, so please take care to also comply with the terms for that library.

Jump To