1 <meta name=
"doc-family" content=
"apps">
2 <h1>Create Your First App
</h1>
6 This tutorial walks you through creating your first Chrome App.
7 Chrome Apps are structured similarly to extensions
8 so current developers will recognize the manifest and packaging methods.
10 you'll just need to produce a zip file of your code and assets
11 in order to
<a href=
"publish_app">publish
</a> your app.
15 A Chrome App contains these components:
19 <li>The
<strong>manifest
</strong> tells Chrome about your app, what it is,
20 how to launch it and the extra permissions that it requires.
</li>
21 <li>The
<strong>background script
</strong> is used to create the event page
22 responsible for managing the app life cycle.
</li>
23 <li>All code must be included in the Chrome App package. This includes HTML, JS, CSS
24 and Native Client modules.
</li>
25 <li>All
<strong>icons
</strong> and other assets must be included
26 in the package as well.
</li>
31 Want to play with the code?
33 <a href=
"https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/hello-world">hello-world
</a>
37 <h2 id=
"one">Step
1: Create the manifest
</h2>
40 First create your
<code>manifest.json
</code> file
41 (
<a href=
"manifest">Formats: Manifest Files
</a>
42 describes this manifest in detail):
45 <pre data-filename=
"manifest.json">
47 "name":
"Hello World!",
48 "description":
"My first Chrome App.",
50 "manifest_version":
2,
53 "scripts": [
"background.js"]
56 "icons": {
"16":
"calculator-16.png",
"128":
"calculator-128.png" }
62 Chrome Apps
<b>must
</b> use
63 <a href=
"manifestVersion">manifest version
2</a>.
66 <h2 id=
"two">Step
2: Create the background script
</h2>
69 Next create a new file called
<code>background.js
</code>
70 with the following content:
73 <pre data-filename=
"background.js">
74 chrome.app.runtime.onLaunched.addListener(function() {
75 chrome.app.window.create('window.html', {
85 In the above sample code,
86 the
<a href=
"app_lifecycle#lifecycle">onLaunched event
</a>
87 will be fired when the user starts the app.
88 It then immediately opens a window for the app of the specified width and height.
89 Your background script may contain additional listeners,
90 windows, post messages, and launch data,
91 all of which are used by the event page to manage the app.
94 <h2 id=
"three">Step
3: Create a window page
</h2>
97 Create your
<code>window.html
</code> file:
100 <pre data-filename=
"window.html">
106 <div
>Hello, world!
</div
>
111 <h2 id=
"four">Step
4: Create the icons
</h2>
114 Copy these icons to your app folder:
118 <li><a href=
"{{static}}/images/calculator-16.png">calculator-
16.png
</a></li>
119 <li><a href=
"{{static}}/images/calculator-128.png">calculator-
128.png
</a></li>
122 <h2 id=
"five">Step
5: Launch your app
</h2>
124 <h3 id=
"enable">Enable flags
</h3>
127 Many of the Chrome Apps APIs are still experimental,
128 so you should enable experimental APIs
129 so that you can try them out:
133 <li>Go to
<b>chrome://flags
</b>.
</li>
134 <li>Find
"Experimental Extension APIs",
135 and click its
"Enable" link.
</li>
136 <li>Restart Chrome.
</li>
139 <h3 id=
"load">Load your app
</h3>
143 bring up the apps and extensions management page
144 by clicking the settings icon
145 <img src=
"{{static}}/images/hotdogmenu.png" width=
"29" height=
"29" alt=
""
146 style=
"margin-top:0" />
147 and choosing
<b>Tools
> Extensions
</b>.
151 Make sure the
<b>Developer mode
</b>
152 checkbox has been selected.
156 Click the
<b>Load unpacked extension
</b> button,
157 navigate to your app's folder
161 <h3 id=
"open">Open new tab and launch
</h3>
164 Once you've loaded your app,
166 and click on your new app icon.
169 <h3 id=
"open">Or, load and launch from command line
</h3>
172 These command line options to Chrome may help you iterate:
175 <code>--load-and-launch-app=/path/to/app/
</code>
176 installs the unpacked application from the given path, and
177 launches it. If the application is already running it is reloaded
178 with the updated content.
181 <code>--app-id=ajjhbohkjpincjgiieeomimlgnll
</code> launches an app
182 already loaded into Chrome. It does not restart any previously running
183 app, but it does launch the new app with any updated content.
188 <p class=
"backtotop"><a href=
"#top">Back to top
</a></p>