Create Your First App

This tutorial walks you through creating your first packaged app. Packaged apps are structured similarly to extensions so current developers will recognize the manifest and packaging methods. When you're done, you'll just need to produce a zip file of your code and assets in order to publish your app.

A packaged app contains these components:

API Samples: Want to play with the code? Check out the hello-world sample.

Step 1: Create the manifest

First create your manifest.json file (Formats: Manifest Files describes this manifest in detail):

{
  "name": "Hello World!",
  "description": "My first packaged app.",
  "version": "0.1",
  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  },
  "icons": { "16": "calculator-16.png", "128": "calculator-128.png" }
}

Important: Packaged apps must use manifest version 2.

Step 2: Create the background script

Next create a new file called background.js with the following content:

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('window.html', {
    'width': 400,
    'height': 500
  });
});

In the above sample code, the onLaunched event will be fired when the user starts the app. It then immediately opens a window for the app of the specified width and height. Your background script may contain additional listeners, windows, post messages, and launch data, all of which are used by the event page to manage the app.

Step 3: Create a window page

Create your window.html file:

<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <div>Hello, world!</div>
  </body>
</html>

Step 4: Create the icons

Copy these icons to your app folder:

Step 5: Launch your app

Enable flags

Many of the packaged apps APIs are still experimental, so you should enable experimental APIs so that you can try them out:

Load your app

To load your app, bring up the apps and extensions management page by clicking the wrench icon and choosing Tools > Extensions.

Make sure the Developer mode checkbox has been selected.

Click the Load unpacked extension button, navigate to your app's folder and click OK.

Open new tab and launch

Once you've loaded your app, open a New Tab page and click on your new app icon.

Back to top