# expo-to-pwa

> Convert An Expo App To A PWA With Just One Command

Latest version **1.0.6** (published 2021-10-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install expo-to-pwa
pnpm add expo-to-pwa
yarn add expo-to-pwa
bun add expo-to-pwa
```

Provides the command `expo-to-pwa`.

## 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.6 |
| Published | 2021-10-15 |
| First published | 2021-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Muhammad Shaheer Turab |
| Maintainers | muhammad-shaheer-turab |
| Keywords | expo, pwa, react, native, react-native, web |

## Links

- npm: https://www.npmjs.com/package/expo-to-pwa
- npm.io page: https://npm.io/package/expo-to-pwa

## 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.6 (latest) — 2021-10-15
- 1.0.5 — 2021-10-15
- 1.0.4 — 2021-10-15
- 1.0.3 — 2021-10-14
- 1.0.2 — 2021-10-14
- 1.0.1 — 2021-10-14
- 1.0.0 — 2021-10-14

## README

# Expo PWA Enabler

<br />

 This Package Allows You To Use A Single Command To Enable PWA Building In Your Expo Project

<br />

---

<br />

## How To Use

<br />

Using This Package Is As Easy As Running A Single Command

<br />

```bash

    #First cd Into Your Expo Project
    cd my_expo_project

    #Next run Command To Build And Serve!
    npx expo-to-pwa -s

```

| Available Switches |                                                                       Effect                                                                                                 |
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|       NONE         |   The Script Only Makes Necessary Changes To The File Structure <br><br> New Dev-Dependencies Are ***NOT*** Installed <br><br> You Will Have To Run `$yarn` Yourself               |
|           <br>     |                                                                                                                                                                              |
|    **-y**             |   The Script Runs `$yarn` (Installs Dev-Dependencies) As Well Along With Making Necessary Changes <br><br> No `$expo build:web` Is Run, i.e The Project is Not Converted To Static Assets, You Will Have To run It Yourself     |
|           <br>     |                                                                                                                                                                              |
|     -b             |   The Script Makes Necessary Changes And Builds The Web Assets By Running `$expo build:web`. No Server Is Started.                                                                                                       |
|           <br>     |                                                                                                                                                                              |
|     -s             |  The Scripts Installs The Dev-Dependencies Needed, Builds Static Resources AND Serves The App On localhost:5000 via `$npx serve web-build`. Recommended Since It Is An All In One Solution For Testing Your App                                                                               |

## How Does The Script Work Under The Hood

<br>

The Scrips Brings The Following Changes To Your App:

<br>

1. Renames `App.js` to `MainApp.js`
1. Creates A New `App.js` File Which Calls the `MainApp.js` (Meaning Overall, Your App Will Not Have Any Changes In The Way It Works) **AND** Registers A Service Worker
1. Creates A Directory Called `src`
1. Adds A Service Worker And A Service Worker Registerer To The `src` Directory
1. Adds Dev-Dependencies (Not Installed If No Command Issued) To Your `package.json`

### Optional Workings From 1st Switch

1. Runs `$yarn` To Install The Dev-Dependencies Added To The package.json ***SWITCH: -y***
1. Runs $yarn And $expo build:web ***SWITCH: -b***
1. Runs \$yarn, \$expo build:web, And Then $npx serve web-build Which Allows You To Visit [localhost:5000](http://localhost:5000/) To View Your App ***SWITCH: -s***

### Optional Second Switch

1. ***In Case You Get The Error 11***, Which Occours When You Run The Script Twice You Can Use The ***`-re`*** Flag, Which Replaces The `MainApp.js` With `App.js`.

<br>

<hr>

<br>

## Other Ways Of Using The Script

<br>

The Preffered Way Of Using Is Via NPX Which Should Come PreInstalled With Node And NPM.

<br>

> ### ***The Reason Why NPX Is Preffered Over Other Methods Is Because You Do Not Have To Install It Either Globally Or Locally***

<br>

The Following Is An Example Of Using It With NPX

```bash
    #Navigate To The Project Library
    cd my_app

    #Run The Script
    npx expo-to-pwa -s 

    #Or Use The -b or -y flag as per need

    #Second Time
    npx expo-to-pwa -s -re

```

### By Installing Globally (*NOT RECCOMENDED*)

<br>

First Install Globally Using NPM

```bash
    npm i -g expo-to-pwa
```

Then Use In Project

```bash
    #Navigate To Project Then:
    expo-to-pwa -s
    #Any Or No FLag As Per Your Need
```

### By Installing As A Dev-Dependency

<br>

First Install

```bash
    npm i -D expo-to-pwa
```

Then Update package.json

```json
    scripts:{
        //... Other Scripts
        "build-pwa":"expo-to-pwa -s"
        //name the script any thing you want
        //replace -s with any switch you want
    }
```

Then Run The Script

```bash
    #npm
    npm run build-pwa           #or whatever you named the script
    #yarn
    yarn build-pwa              #or whatever you named the script
```

## Warnings

<br>

> #### ***In Case your App Contains A "MainApplication.js" File, Please Rename It And Update Imports*** <br><br> ***Failing To Do So Might Result In Your File Being Overwritten***

<br>

---
<br>

---

<br>

> #### ***In Case your App Contains A "src" Folder, Please Rename It And Update Imports*** <br><br> ***Failing To Do So Might Result In Your Folder Being Overwritten***

## How To Use The `-re` Flag Without Using The 1st Flags Available

<br>

In Case You Do Not Want To Add The `-y`, `-b`, or `-s` Flags, For Any Reason (Which Should Not Be The Case In Most Instances), Just Add A `-` To In As The 1st Flag

## Known Issues

<br>

This Package Works Only With Plain JS Projects, It Cannot Work With TS Projects, **How Ever You May Rename The App.js to App.ts And MainApp.js To MainApp.ts**

## Licenses

<br>

This Has Been Licensed By Muhammad Shaheer Turab, Under The [**MIT Liscence**](https://en.m.wikipedia.org/wiki/MIT_License).

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