Integrations

Polymer Integration

Polymer is a lightweight library developed by Google that helps you create custom web components using a simple and declarative syntax. It provides features to make web component development more straightforward and efficient.

Integration Approach

Aurelia offers robust support for integrating Web Components, including those created with Polymer. The integration allows you to:

  • Use Polymer components directly in Aurelia applications

  • Leverage two-way data binding

  • Seamlessly interact with Polymer-created custom elements

Compatibility Considerations

  • Supported Polymer Versions: Polymer 1.x and 2.x

  • Aurelia Version: Aurelia 1.x

  • Recommended Polyfills: Web Components polyfills for broader browser support

Installation

Prerequisites

Before integrating Polymer with Aurelia, ensure you have the following:

  • Node.js (latest LTS)

  • Aurelia CLI or an existing Aurelia 1.x project

  • Basic understanding of Web Components

Required Dependencies

Install the following dependencies:

Installation Steps

1. Add Polyfills

In your project's entry point (typically main.js), include Web Components polyfills:

2. Configure Aurelia Plugin

Update your main.js to register the Web Components plugin:

3. Import Polymer Components

You can now import and use Polymer components in your Aurelia views:

Usage Patterns

Importing Polymer Components

Direct Import

Import Polymer components in your Aurelia component:

View-Based Import

You can also import components directly in your view:

Binding to Polymer Components

One-Way Binding

Bind Aurelia view-model properties to Polymer component attributes:

Two-Way Binding

Use .two-way binding for two-way data synchronization:

Event Handling

Standard Event Binding

Bind Polymer component events using Aurelia's event binding:

Nested Polymer Components

Combine multiple Polymer components:

Examples

Basic Component Integration

Simple Form Example

Advanced Example: Custom Element Wrapper

Last updated

Was this helpful?