# react-google-stories

> React component to integrate Google Stories

Latest version **1.0.4** (published 2021-01-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-google-stories
pnpm add react-google-stories
yarn add react-google-stories
bun add react-google-stories
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-01-01 |
| First published | 2020-12-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 16.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Victor Abeledo |
| Maintainers | abeledovictor |
| Keywords | google, google-stories, react, typescript, npm, stories |

## Links

- npm: https://www.npmjs.com/package/react-google-stories
- Repository: https://github.com/abeledovictor/react-google-stories
- Homepage: https://github.com/abeledovictor/react-google-stories#readme
- Issues: https://github.com/abeledovictor/react-google-stories/issues
- npm.io page: https://npm.io/package/react-google-stories

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2021-01-01
- 1.0.3 — 2021-01-01
- 1.0.2 — 2020-12-31
- 1.0.1 — 2020-12-31
- 1.0.0 — 2020-12-31

## README

# react-google-stories BETA

### Easily add Google Stories to your React App
First API to play nicely with google stories

### Setup
- Add this script to your index.html file
```js
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <script async custom-element="amp-video"
        src="https://cdn.ampproject.org/v0/amp-video-0.1.js"></script>
    <script async custom-element="amp-story"
        src="https://cdn.ampproject.org/v0/amp-story-1.0.js"></script>
```

**It's important to note that to have a valid AMP story, the body tag element must have only one AmpStory component; all other elements are contained in the AmpStory.**

#### Create react app setup example
If you had a new CRA project, you should need to
- `npx create-react-app my-google-stories-app`
- `cd my-google-stories-app`
- Install react-google-stories `yarn add react-google-stories`
- Remove the return code from _App.js_
- Paste this template:

```js
import { AmpStoryGridLayer, AmpStory, AmpStoryPage, AmpImg, AmpHeader, AmpParagraph } from 'react-google-stories'

function App() {
  return (
    <AmpStory
      title="Example title"
      publisher="Example publisher"
      publisher-logo-src="logo128.png"
      poster-portrait-src="3x4.jpg"
    >
      <AmpStoryPage id="first">
        <AmpStoryGridLayer template="fill">
          <AmpImg src="logo512.png" height="720" width="1280" layout="responsive" />
        </AmpStoryGridLayer>
        <AmpStoryGridLayer template="vertical">
            <AmpHeader level={1} title="Title 1" />
            <AmpParagraph text="Subtitle" />
        </AmpStoryGridLayer>
      </AmpStoryPage>

      <AmpStoryPage id="second">
        <AmpStoryGridLayer template="fill">
          <AmpImg src="logo512.png" height="720" width="1280" layout="responsive" />
        </AmpStoryGridLayer>
        <AmpStoryGridLayer template="vertical">
            <AmpHeader level={1} title="Title 2" />
            <AmpParagraph text="Subtitle" />
        </AmpStoryGridLayer>

      </AmpStoryPage>
    </AmpStory>
  );
}

export default App;
```

- Inside `public/index.html` file remove everything inside `body` tag and add `id="root"` to it: `<body id="root"></body>`

- Add the following scripts to head at `public/index.html` :

```html
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <script async custom-element="amp-video"
        src="https://cdn.ampproject.org/v0/amp-video-0.1.js"></script>
    <script async custom-element="amp-story"
        src="https://cdn.ampproject.org/v0/amp-story-1.0.js"></script>
```

- WARNING: **Each AmpStoryPage should have a unique id**

- Example URL [Joy of pets](https://abeledovictor.github.io/react-google-stories-pets-example/)

- Example repo [Joy of pets repo](https://github.com/abeledovictor/react-google-stories-pets-example)

---
_Source: https://npm.io/package/react-google-stories · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
