Get the Polymer library
Table of contents
Installing with Bower
The recommended way to install Polymer 1.0 is through Bower. To install Bower, see the Bower web site.
Bower removes the hassle of dependency management when developing or consuming elements. When you install a component, Bower makes sure any dependencies are installed as well.
Project setup
If you haven’t created a bower.json
file for your application, run this
command from the root of your project:
bower init
This generates a basic bower.json
file. Some of the questions, like
“What kind of modules do you expose,” can be ignored by pressing Enter.
The next step is to install Polymer:
bower install --save Polymer/polymer
Bower adds a bower_components/
folder in the root of your project and
fills it with Polymer and its dependencies.
The --save
adds the item as a dependency in your app’s bower.json:
{ "name": "my-project", "version": "0.0.0", "dependencies": { "polymer": "Polymer/polymer#^1.X.Y" } }
Where 1.X.Y
is the current stable version of
Polymer. For example, if the current version is 1.3.1,
the dependency line will show #^1.3.1
, which means that your project
requires a Polymer version equal to or greater than 1.3.1,
but less than 2.0.
Note: Bower versions prior to 1.7.5 defaulted to a narrower version
range, using the tilde operator. For example, #~1.3.1
, which
matches any version equal to or greater than 1.3.1, but less than
1.4.0. If you’re using an older version of Bower, we recommend
updating to the latest version and checking the version ranges in your
bower.json
files.
Updating packages
When a new version of Polymer is available, run bower update
in your app directory to update your copy:
bower update
This updates all packages in bower_components/
to the latest stable version.
If the packages don’t update as expected, check the version ranges in your
bower.json
file as described in Installing with Bower.
If they’re correct, try clearing Bower’s cache and re-running the update:
bower cache clean
bower update
Installing from ZIP files
Click the button to download Polymer 1.0 as a ZIP file.
When you download Polymer as a ZIP file, you get all of the dependencies bundled into a single archive. It’s a great way to get started because you don’t need to install any additional tools. However, if you need to install additional elements, like the Material Design element set, you’ll have to download them as ZIPs as well, or switch to Bower. For this reason we recommend starting with Bower if possible.
Expand the ZIP file in your project directory to create a bower_components
folder.
Unlike Bower, the ZIP file doesn’t provide a built-in method for updating dependencies. You can manually update components with a new ZIP file.
Note: If you decide to install Bower later, you can use Bower to update the components you installed from the ZIP file. Follow the instructions in Updating packages.
Using the Polyfills
When you install Polymer (either with Bower or as a ZIP), you get the
Web Components polyfill library.
For this version of Polymer, you need the webcomponents-lite
version of the
library, which doesn’t include the shadow DOM polyfill.
Using the polyfills ensures that you can use Polymer with browsers that don’t support the Web Components specifications natively.
Element starter
If you want to publish an element for others to use, the
<seed-element>
boilerplate is a good starting point. It comes with the tools
you need for building, testing and documenting your element.
Create a reusable element guides you through the steps to create, test, document and publish your element.
Polymer Starter Kit
A “batteries-included” application template, the Polymer Starter Kit includes a responsive application layout, tooling for testing and deployment, and even optional support for advanced features like offline access and push notifications.
Check out the Polymer Starter Kit (PSK) tutorials to learn how to:
- Install, build, and locally run the PSK.
- Create a new page of content.
- Deploy the PSK to the web.
Contributing to the Project
If you’d like to hack on the project or submit a pull request, you can visit the GitHub repo. Because there are a number of dependencies, if you’re just trying to use Polymer in a project we suggest you install Polymer with Bower instead of git.
Next steps
Now that you’ve installed Polymer it’s time to learn the core concepts. Continue on to:
If you’re coming from Polymer 0.5, check out the Migration guide.