Convert Figma logo to code with AI

aws-amplify logoamplify-js

A declarative JavaScript library for application development using cloud services.

9,415
2,115
9,415
638

Top Related Projects

A framework for building native applications using React

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

164,677

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

32,626

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.

25,724

Quasar Framework - Build high-performance VueJS user interfaces in record time

⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.

Quick Overview

Amplify JS is an open-source JavaScript library that provides a declarative interface for building cloud-enabled applications. It offers a set of tools and services for frontend and mobile developers to easily integrate AWS services into their applications, including authentication, analytics, API management, and more.

Pros

  • Simplifies integration of AWS services into JavaScript applications
  • Provides a consistent API across different platforms (web, React Native, etc.)
  • Offers offline support and data synchronization capabilities
  • Extensive documentation and active community support

Cons

  • Learning curve can be steep for developers new to AWS
  • Some users report performance issues with large-scale applications
  • Occasional breaking changes between major versions
  • Limited customization options for certain features

Code Examples

  1. Authentication with Amplify
import { Amplify, Auth } from 'aws-amplify';

Amplify.configure({
  Auth: {
    // AWS Cognito configuration
  }
});

async function signIn(username, password) {
  try {
    const user = await Auth.signIn(username, password);
    console.log('Sign in successful:', user);
  } catch (error) {
    console.error('Error signing in:', error);
  }
}
  1. API calls with Amplify
import { API } from 'aws-amplify';

async function fetchData() {
  try {
    const response = await API.get('myapi', '/items');
    console.log('API response:', response);
  } catch (error) {
    console.error('Error fetching data:', error);
  }
}
  1. Storage operations with Amplify
import { Storage } from 'aws-amplify';

async function uploadFile(file) {
  try {
    const result = await Storage.put(file.name, file, {
      contentType: file.type
    });
    console.log('File uploaded successfully:', result);
  } catch (error) {
    console.error('Error uploading file:', error);
  }
}

Getting Started

  1. Install Amplify CLI:

    npm install -g @aws-amplify/cli
    
  2. Install Amplify library in your project:

    npm install aws-amplify
    
  3. Initialize Amplify in your project:

    amplify init
    
  4. Add Amplify services to your project:

    amplify add auth
    amplify add api
    
  5. Push changes to the cloud:

    amplify push
    
  6. Import and configure Amplify in your application:

    import { Amplify } from 'aws-amplify';
    import awsconfig from './aws-exports';
    Amplify.configure(awsconfig);
    

Now you can start using Amplify services in your application!

Competitor Comparisons

A framework for building native applications using React

Pros of React Native

  • Allows for cross-platform mobile app development with a single codebase
  • Large and active community, extensive third-party libraries
  • Native performance and look-and-feel on both iOS and Android

Cons of React Native

  • Steeper learning curve for developers new to mobile development
  • Occasional challenges with native module integration
  • May require platform-specific code for complex features

Code Comparison

React Native:

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

const App = () => (
  <View style={styles.container}>
    <Text>Hello, React Native!</Text>
  </View>
);

Amplify JS:

import { Amplify, Auth } from 'aws-amplify';
import awsconfig from './aws-exports';

Amplify.configure(awsconfig);

async function signIn(username, password) {
  try {
    await Auth.signIn(username, password);
  } catch (error) {
    console.log('Error signing in:', error);
  }
}

While React Native focuses on UI components and cross-platform development, Amplify JS provides AWS service integrations and authentication utilities. React Native is ideal for building mobile apps, whereas Amplify JS is better suited for adding cloud capabilities to web and mobile applications.

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

Pros of Ionic Framework

  • Comprehensive UI component library for building cross-platform mobile and web applications
  • Strong community support and extensive documentation
  • Integrates well with popular web frameworks like Angular, React, and Vue

Cons of Ionic Framework

  • Steeper learning curve for developers new to hybrid app development
  • Performance may not match native apps for complex, graphics-intensive applications
  • Dependency on Cordova plugins for accessing certain native device features

Code Comparison

Ionic Framework:

import { Component } from '@angular/core';
import { IonicModule } from '@ionic/angular';

@Component({
  selector: 'app-home',
  template: '<ion-button>Click me</ion-button>',
  standalone: true,
  imports: [IonicModule],
})
export class HomePage {}

Amplify JS:

import { Amplify, Auth } from 'aws-amplify';
import awsconfig from './aws-exports';

Amplify.configure(awsconfig);

async function signIn(username, password) {
  try {
    await Auth.signIn(username, password);
  } catch (error) {
    console.log('Error signing in:', error);
  }
}

The code examples showcase the different focus areas of each library. Ionic Framework provides UI components and integrates with popular web frameworks, while Amplify JS focuses on AWS service integration and authentication.

164,677

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Pros of Flutter

  • Cross-platform development for mobile, web, and desktop from a single codebase
  • Rich set of pre-designed widgets for faster UI development
  • Hot reload feature for quick iterations and testing

Cons of Flutter

  • Larger app size compared to native applications
  • Limited access to platform-specific features without plugins
  • Steeper learning curve for developers new to Dart language

Code Comparison

Flutter (UI component):

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Text('Hello, Flutter!'),
    );
  }
}

Amplify JS (API call):

import { API } from 'aws-amplify';

async function getData() {
  const apiData = await API.get('myApi', '/items');
  console.log(apiData);
}

Flutter focuses on UI development with a widget-based approach, while Amplify JS provides AWS service integrations for web and mobile apps. Flutter offers a more comprehensive framework for building entire applications, whereas Amplify JS specializes in cloud-based features and backend integration. The choice between them depends on project requirements, target platforms, and the desired level of AWS integration.

32,626

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.

Pros of Expo

  • Simpler setup and development process for React Native apps
  • Extensive set of pre-built components and APIs
  • Easier deployment and over-the-air updates

Cons of Expo

  • Less flexibility and customization options compared to bare React Native
  • Larger app size due to included libraries and components

Code Comparison

Expo example:

import React from 'react';
import { Text, View } from 'react-native';
import { Camera } from 'expo-camera';

export default function App() {
  return (
    <View style={{ flex: 1 }}>
      <Camera style={{ flex: 1 }} />
      <Text>Hello, Expo!</Text>
    </View>
  );
}

Amplify example:

import React from 'react';
import { Text, View } from 'react-native';
import { Auth } from 'aws-amplify';

export default function App() {
  return (
    <View>
      <Text>Hello, Amplify!</Text>
      <Button onPress={() => Auth.signIn(username, password)}>Sign In</Button>
    </View>
  );
}

While Expo focuses on providing a comprehensive development environment for React Native apps, Amplify-js is more specialized in integrating AWS services into JavaScript applications. Expo offers a smoother development experience for mobile apps, while Amplify provides robust cloud integration capabilities.

25,724

Quasar Framework - Build high-performance VueJS user interfaces in record time

Pros of Quasar

  • Comprehensive UI component library with Material Design support
  • Cross-platform development for web, mobile, and desktop from a single codebase
  • Built-in CLI for rapid project setup and development

Cons of Quasar

  • Steeper learning curve due to its extensive feature set
  • Less integration with AWS services compared to Amplify
  • Potentially larger bundle size for simple applications

Code Comparison

Quasar (Vue.js-based):

<template>
  <q-btn color="primary" @click="handleClick">Click me</q-btn>
</template>

<script>
export default {
  methods: {
    handleClick() {
      // Button click logic
    }
  }
}
</script>

Amplify (React-based):

import { Button } from '@aws-amplify/ui-react';

function MyComponent() {
  const handleClick = () => {
    // Button click logic
  };

  return <Button onClick={handleClick}>Click me</Button>;
}

Quasar focuses on providing a complete UI framework with cross-platform capabilities, while Amplify specializes in AWS integrations and cloud-powered features. Quasar offers more flexibility for general-purpose applications, whereas Amplify excels in AWS-centric projects with built-in authentication and data management.

⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.

Pros of NativeScript

  • Allows developers to build truly native mobile apps using JavaScript, TypeScript, or Angular
  • Provides direct access to native platform APIs, enabling deeper integration with device features
  • Offers a single codebase for both iOS and Android platforms, reducing development time and effort

Cons of NativeScript

  • Steeper learning curve compared to Amplify.js, especially for developers new to mobile development
  • Smaller community and ecosystem compared to more established frameworks like React Native
  • May require platform-specific knowledge for advanced customization and optimization

Code Comparison

NativeScript (XML and TypeScript):

<Page>
  <StackLayout>
    <Label text="Hello, NativeScript!" />
    <Button text="Click me" tap="onTap" />
  </StackLayout>
</Page>
export function onTap() {
  console.log("Button tapped!");
}

Amplify.js (React):

import { Amplify } from 'aws-amplify';
import { withAuthenticator } from '@aws-amplify/ui-react';

function App() {
  return <h1>Hello, Amplify!</h1>;
}

export default withAuthenticator(App);

NativeScript focuses on creating native mobile apps with JavaScript, while Amplify.js is primarily used for building cloud-connected web and mobile applications with AWS services. NativeScript offers more control over native UI and device features, whereas Amplify.js provides easier integration with AWS services and authentication workflows.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

AWS Amplify

current aws-amplify package version weekly downloads GitHub Workflow Status (with event) code coverage join discord

Reporting Bugs / Feature Requests

Open Bugs Feature Requests Closed Issues

Note aws-amplify 6 has been released. If you are looking for upgrade guidance click here

AWS Amplify is a JavaScript library for frontend and mobile developers building cloud-enabled applications

AWS Amplify provides a declarative and easy-to-use interface across different categories of cloud operations. AWS Amplify goes well with any JavaScript based frontend workflow and React Native for mobile developers.

Our default implementation works with Amazon Web Services (AWS), but AWS Amplify is designed to be open and pluggable for any custom backend or service.

Visit our documentation site to learn more about AWS Amplify. Please see the Amplify JavaScript page for information around the full list of features we support.

Features

CategoryAWS ProviderDescription
AuthenticationAmazon CognitoAPIs and Building blocks to create Authentication experiences.
AnalyticsAmazon PinpointCollect Analytics data for your application including tracking user sessions.
REST APIAmazon API GatewaySigv4 signing and AWS auth for API Gateway and other REST endpoints.
GraphQL APIAWS AppSyncInteract with your GraphQL or AWS AppSync endpoint(s).
DataStoreAWS AppSyncProgramming model for shared and distributed data, with simple online/offline synchronization.
StorageAmazon S3Manages content in public, protected, private storage buckets.
Geo (Developer preview)Amazon Location ServiceProvides APIs and UI components for maps and location search for JavaScript-based web apps.
Push NotificationsAmazon PinpointAllows you to integrate push notifications in your app with Amazon Pinpoint targeting and campaign management support.
InteractionsAmazon LexCreate conversational bots powered by deep learning technologies.
PubSubAWS IoTProvides connectivity with cloud-based message-oriented middleware.
Internationalization---A lightweight internationalization solution.
Cache---Provides a generic LRU cache for JavaScript developers to store data with priority and expiration settings.
PredictionsVarious*Connect your app with machine learning services like NLP, computer vision, TTS, and more.
  • Predictions utilizes a range of Amazon's Machine Learning services, including: Amazon Comprehend, Amazon Polly, Amazon Rekognition, Amazon Textract, and Amazon Translate.

Getting Started

AWS Amplify is available as aws-amplify on npm.

To get started pick your platform from our Getting Started home page

Notice:

Amplify 6.x.x has breaking changes. Please see the breaking changes on our migration guide

Amplify 5.x.x has breaking changes. Please see the breaking changes below:

  • If you are using default exports from any Amplify package, then you will need to migrate to using named exports. For example:

    - import Amplify from 'aws-amplify';
    + import { Amplify } from 'aws-amplify'
    
    - import Analytics from '@aws-amplify/analytics';
    + import { Analytics } from '@aws-amplify/analytics';
    // or better
    + import { Analytics } from 'aws-amplify';
    
    - import Storage from '@aws-amplify/storage';
    + import { Storage } from '@aws-amplify/storage';
    // or better
    + import { Storage } from 'aws-amplify';
    
  • Datastore predicate syntax has changed, impacting the DataStore.query, DataStore.save, DataStore.delete, and DataStore.observe interfaces. For example:

    - await DataStore.delete(Post, (post) => post.status('eq', PostStatus.INACTIVE));
    + await DataStore.delete(Post, (post) => post.status.eq(PostStatus.INACTIVE));
    
    - await DataStore.query(Post, p => p.and( p => [p.title('eq', 'Amplify Getting Started Guide'), p.score('gt', 8)]));
    + await DataStore.query(Post, p => p.and( p => [p.title.eq('Amplify Getting Started Guide'), p.score.gt(8)]));
    
  • Storage.list has changed the name of the maxKeys parameter to pageSize and has a new return type that contains the results list. For example:

    - const photos = await Storage.list('photos/', { maxKeys: 100 });
    - const { key } = photos[0];
    
    + const photos = await Storage.list('photos/', { pageSize: 100 });
    + const { key } = photos.results[0];
    
  • Storage.put with resumable turned on has changed the key to no longer include the bucket name. For example:

    - let uploadedObjectKey;
    - Storage.put(file.name, file, {
    -   resumable: true,
    -   // Necessary to parse the bucket name out to work with the key
    -   completeCallback: (obj) => uploadedObjectKey = obj.key.substring( obj.key.indexOf("/") + 1 )
    - }
    
    + let uploadedObjectKey;
    + Storage.put(file.name, file, {
    +   resumable: true,
    +   completeCallback: (obj) => uploadedObjectKey = obj.key
    + }
    
  • Analytics.record no longer accepts string as input. For example:

    - Analytics.record('my example event');
    + Analytics.record({ name: 'my example event' });
    
  • The JS export has been removed from @aws-amplify/core in favor of exporting the functions it contained.

  • Any calls to Amplify.Auth, Amplify.Cache, and Amplify.ServiceWorker are no longer supported. Instead, your code should use the named exports. For example:

    - import { Amplify } from 'aws-amplify';
    - Amplify.configure(...);
    - // ...
    - Amplify.Auth.signIn(...);
    
    + import { Amplify, Auth } from 'aws-amplify';
    + Amplify.configure(...);
    + // ...
    + Auth.signIn(...);
    

Amplify 4.x.x has breaking changes for React Native. Please see the breaking changes below:

  • If you are using React Native (vanilla or Expo), you will need to add the following React Native community dependencies:
    • @react-native-community/netinfo
    • @react-native-async-storage/async-storage
// React Native
yarn add aws-amplify amazon-cognito-identity-js @react-native-community/netinfo @react-native-async-storage/async-storage
npx pod-install

// Expo
yarn add aws-amplify @react-native-community/netinfo @react-native-async-storage/async-storage

Amplify 3.x.x has breaking changes. Please see the breaking changes below:

  • AWS.credentials and AWS.config don’t exist anymore in Amplify JavaScript.
    • Both options will not be available to use in version 3. You will not be able to use and set your own credentials.
    • For more information on this change, please see the AWS SDK for JavaScript v3
  • aws-sdk@2.x has been removed from Amplify@3.x.x in favor of version 3 of aws-sdk-js. We recommend to migrate to aws-sdk-js-v3 if you rely on AWS services that are not supported by Amplify, since aws-sdk-js-v3 is imported modularly.

If you can't migrate to aws-sdk-js-v3 or rely on aws-sdk@2.x, you will need to import it separately.

  • If you are using exported paths within your Amplify JS application, (e.g. import from "@aws-amplify/analytics/lib/Analytics") this will now break and no longer will be supported. You will need to change to named imports:

    import { Analytics } from 'aws-amplify';
    
  • If you are using categories as Amplify.<Category>, this will no longer work and we recommend to import the category you are needing to use:

    import { Auth } from 'aws-amplify';
    

DataStore Docs

For more information on contributing to DataStore / how DataStore works, see the DataStore Docs

NPM DownloadsLast 30 Days