create-shopify-firebase-app 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mayank Khan Singh DeSouza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,404 @@
1
+ # create-shopify-firebase-app
2
+
3
+ > Create Shopify apps powered by Firebase. One command. Zero framework. Fully serverless.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/create-shopify-firebase-app.svg)](https://www.npmjs.com/package/create-shopify-firebase-app)
6
+ [![Downloads](https://img.shields.io/npm/dm/create-shopify-firebase-app.svg)](https://www.npmjs.com/package/create-shopify-firebase-app)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8
+
9
+ ```bash
10
+ npx create-shopify-firebase-app my-app
11
+ ```
12
+
13
+ <p align="center">
14
+ <img src="https://img.shields.io/badge/Shopify-App-7AB55C?logo=shopify&logoColor=white" />
15
+ <img src="https://img.shields.io/badge/Firebase-Backend-FFCA28?logo=firebase&logoColor=black" />
16
+ <img src="https://img.shields.io/badge/TypeScript-Functions-3178C6?logo=typescript&logoColor=white" />
17
+ <img src="https://img.shields.io/badge/Express-Server-000000?logo=express&logoColor=white" />
18
+ </p>
19
+
20
+ ---
21
+
22
+ ## What is this?
23
+
24
+ The **Firebase alternative** to `shopify app init`. Instead of Remix + Prisma + Vercel, you get:
25
+
26
+ - **Firebase Cloud Functions** (Express + TypeScript) for your backend
27
+ - **Cloud Firestore** for sessions and app data (auto-scaling, free tier)
28
+ - **Firebase Hosting** for your embedded admin dashboard (free)
29
+ - **Vanilla HTML/JS + App Bridge** for the frontend (no React, no build step)
30
+ - **Theme App Extension** for storefront UI (works on all Shopify plans)
31
+ - **Production-ready** OAuth, session tokens, webhooks, GDPR handlers — all included
32
+
33
+ One `npx` command scaffolds everything, installs dependencies, wires up Firebase, and initializes git. You're ready to `firebase deploy`.
34
+
35
+ ---
36
+
37
+ ## Quick Start
38
+
39
+ ### Prerequisites
40
+
41
+ | Tool | Install |
42
+ |------|---------|
43
+ | Node.js 18+ | [nodejs.org](https://nodejs.org/) |
44
+ | Firebase CLI | `npm i -g firebase-tools` |
45
+ | Shopify CLI *(optional)* | `npm i -g @shopify/cli` |
46
+
47
+ ### 1. Create your Shopify app
48
+
49
+ Go to [partners.shopify.com](https://partners.shopify.com/) → **Apps** → **Create app** → **Create app manually**.
50
+ Copy the **Client ID** (API Key) and **Client Secret** (API Secret).
51
+
52
+ ### 2. Create your Firebase project
53
+
54
+ Go to [console.firebase.google.com](https://console.firebase.google.com/) → **Add project**.
55
+ Enable **Cloud Firestore** (production mode). Note the **Project ID**.
56
+
57
+ ### 3. Run the scaffold
58
+
59
+ ```bash
60
+ npx create-shopify-firebase-app my-app
61
+ ```
62
+
63
+ The interactive CLI asks for your credentials and does the rest:
64
+
65
+ ```
66
+ SHOPIFY + FIREBASE Create a new Shopify app
67
+
68
+ ✔ Project directory name: my-app
69
+ ✔ App name: My App
70
+ ✔ Shopify API Key: abc123...
71
+ ✔ Shopify API Secret: ********
72
+ ✔ API Scopes: read_products
73
+ ✔ Firebase Project ID: my-app-12345
74
+
75
+ [1/6] Scaffolding project...
76
+ ✔ Created 27 files in my-app/
77
+
78
+ [2/6] Installing dependencies...
79
+ ✔ Dependencies installed
80
+
81
+ [3/6] Building TypeScript...
82
+ ✔ TypeScript compiled successfully
83
+
84
+ [4/6] Setting up Firebase...
85
+ ✔ Firebase project linked: my-app-12345
86
+
87
+ [5/6] Checking Shopify CLI...
88
+ ✔ Shopify CLI detected
89
+
90
+ [6/6] Initializing git...
91
+ ✔ Git repository initialized with first commit
92
+
93
+ SUCCESS Your Shopify + Firebase app is ready!
94
+
95
+ Next steps:
96
+
97
+ cd my-app
98
+ firebase deploy
99
+ ```
100
+
101
+ ### 4. Deploy & Install
102
+
103
+ ```bash
104
+ cd my-app
105
+ firebase deploy
106
+ ```
107
+
108
+ Then install on your dev store by visiting:
109
+ ```
110
+ https://my-app-12345.web.app/auth?shop=YOUR-STORE.myshopify.com
111
+ ```
112
+
113
+ Or use Shopify CLI for local development:
114
+ ```bash
115
+ shopify app dev
116
+ ```
117
+
118
+ ---
119
+
120
+ ## Why Firebase instead of Remix?
121
+
122
+ | | `shopify app init` (Remix) | `create-shopify-firebase-app` |
123
+ |---|---|---|
124
+ | **Backend** | Remix server | Firebase Cloud Functions (Express) |
125
+ | **Database** | Prisma + PostgreSQL | Cloud Firestore (NoSQL, auto-scaling) |
126
+ | **Frontend** | React + Polaris | Vanilla HTML/JS + App Bridge |
127
+ | **Hosting** | Vercel / Fly.io / Heroku | Firebase Hosting (free tier) |
128
+ | **Auth** | `@shopify/shopify-app-remix` | Manual OAuth (140 lines, you own it) |
129
+ | **Build** | Webpack / Vite | `tsc` (TypeScript compiler, no bundler) |
130
+ | **Deploy** | Varies | `firebase deploy` (one command) |
131
+ | **Cost** | $5-25/month hosting | Free tier covers most apps |
132
+ | **Framework knowledge** | Remix + React required | Express + HTML (that's it) |
133
+ | **Backend code** | ~2000+ lines (framework) | ~350 lines (you own all of it) |
134
+ | **GDPR webhooks** | Auto-handled | Included (ready for App Store) |
135
+ | **Theme extensions** | Supported | Supported (same Shopify format) |
136
+ | **Shopify Functions** | Supported | Supported (add via Shopify CLI) |
137
+
138
+ ### When to use this
139
+
140
+ - Custom apps for a single merchant
141
+ - Public apps with simple admin UIs
142
+ - Teams already using Firebase / Google Cloud
143
+ - You want to understand every line of your app
144
+ - You want free/cheap serverless hosting
145
+
146
+ ### When to use Remix instead
147
+
148
+ - Complex multi-page admin UIs with Polaris React components
149
+ - Large team already invested in the Remix ecosystem
150
+ - You need server-side rendering for your app pages
151
+
152
+ ---
153
+
154
+ ## What's Inside
155
+
156
+ ```
157
+ my-app/
158
+ ├── shopify.app.toml # Shopify app config
159
+ ├── firebase.json # Firebase Hosting + Functions + Firestore
160
+ ├── firestore.rules # Security rules (blocks direct client access)
161
+
162
+ ├── functions/ # ── Backend ──
163
+ │ ├── src/
164
+ │ │ ├── index.ts # Express app + Cloud Function export
165
+ │ │ ├── auth.ts # OAuth 2.0 (install + callback + token storage)
166
+ │ │ ├── verify-token.ts # App Bridge JWT session token middleware
167
+ │ │ ├── admin-api.ts # Your admin dashboard API routes
168
+ │ │ ├── proxy.ts # Storefront-facing App Proxy routes
169
+ │ │ ├── webhooks.ts # Webhook handlers (uninstall + GDPR)
170
+ │ │ ├── firebase.ts # Firebase Admin SDK init
171
+ │ │ └── config.ts # Environment config
172
+ │ └── .env # Your secrets (auto-generated, git-ignored)
173
+
174
+ ├── web/ # ── Frontend ──
175
+ │ ├── index.html # Embedded admin dashboard
176
+ │ ├── js/bridge.js # App Bridge helper (auth, fetch, navigate)
177
+ │ └── css/app.css # Shopify-like styles
178
+
179
+ └── extensions/ # ── Storefront ──
180
+ └── theme-block/
181
+ ├── blocks/app-block.liquid
182
+ ├── assets/app-block.{js,css}
183
+ └── locales/en.default.json
184
+ ```
185
+
186
+ ---
187
+
188
+ ## Architecture
189
+
190
+ ```
191
+ Shopify Admin (iframe)
192
+ ┌─────────────────────────────────────┐
193
+ │ Firebase Hosting (HTML/JS) │
194
+ │ + App Bridge (session tokens) │
195
+ └──────────────┬──────────────────────┘
196
+ │ Bearer <JWT>
197
+
198
+ Firebase Cloud Functions (Express)
199
+ ┌─────────────────────────────────────┐
200
+ │ /auth → OAuth 2.0 flow │
201
+ │ /api/* → Admin API (JWT auth) │
202
+ │ /proxy/* → App Proxy (HMAC) │
203
+ │ /webhooks → Webhooks (HMAC) │
204
+ └──────────────┬──────────────────────┘
205
+
206
+
207
+ Cloud Firestore
208
+ ┌─────────────────────────────────────┐
209
+ │ shopSessions → OAuth tokens │
210
+ │ authNonces → CSRF protection │
211
+ │ (your data) → App-specific │
212
+ └─────────────────────────────────────┘
213
+ ```
214
+
215
+ ### Three Security Layers
216
+
217
+ | Layer | Protects | How |
218
+ |-------|----------|-----|
219
+ | **OAuth 2.0** | App install | HMAC-verified code exchange → Firestore |
220
+ | **Session Token** | Admin API | App Bridge JWT (HS256) verified on every request |
221
+ | **HMAC Signature** | Proxy + Webhooks | SHA-256 timing-safe comparison |
222
+
223
+ ---
224
+
225
+ ## CLI Usage
226
+
227
+ ```bash
228
+ # Interactive (recommended)
229
+ npx create-shopify-firebase-app
230
+
231
+ # With project name
232
+ npx create-shopify-firebase-app my-app
233
+
234
+ # Non-interactive (CI/CD)
235
+ npx create-shopify-firebase-app my-app \
236
+ --api-key=abc123 \
237
+ --api-secret=secret \
238
+ --project-id=my-firebase-project \
239
+ --scopes=read_products,write_products
240
+
241
+ # Help
242
+ npx create-shopify-firebase-app --help
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Development
248
+
249
+ ### Local with Firebase Emulators
250
+
251
+ ```bash
252
+ cd functions
253
+ npm run serve
254
+ # Functions → http://localhost:5001
255
+ # Firestore → http://localhost:8080
256
+ ```
257
+
258
+ ### Local with Shopify CLI
259
+
260
+ ```bash
261
+ shopify app dev
262
+ # Creates tunnel + hot reload
263
+ ```
264
+
265
+ ### Deploy
266
+
267
+ ```bash
268
+ firebase deploy # Everything
269
+ firebase deploy --only functions # Backend only
270
+ firebase deploy --only hosting # Frontend only
271
+ ```
272
+
273
+ ---
274
+
275
+ ## Extending Your App
276
+
277
+ ### Add admin API routes
278
+
279
+ Edit `functions/src/admin-api.ts`:
280
+
281
+ ```typescript
282
+ adminApiRouter.post("/my-endpoint", async (req, res) => {
283
+ const shop = (req as any).shopDomain;
284
+ const token = await getAccessToken(shop);
285
+ // Call Shopify Admin API, write to Firestore, etc.
286
+ res.json({ success: true });
287
+ });
288
+ ```
289
+
290
+ ### Add storefront routes (App Proxy)
291
+
292
+ Edit `functions/src/proxy.ts` and enable `[app_proxy]` in `shopify.app.toml`:
293
+
294
+ ```typescript
295
+ proxyRouter.get("/my-route", (req, res) => {
296
+ if (!verifyProxySignature(req.query)) return res.status(403).json({ error: "Invalid" });
297
+ res.json({ hello: "storefront" });
298
+ });
299
+ ```
300
+
301
+ ### Add webhook handlers
302
+
303
+ Edit `functions/src/webhooks.ts` and register in `shopify.app.toml`:
304
+
305
+ ```typescript
306
+ case "orders/create": {
307
+ const order = req.body;
308
+ // Your logic
309
+ break;
310
+ }
311
+ ```
312
+
313
+ ### Add Firestore collections
314
+
315
+ ```typescript
316
+ import { db } from "./firebase";
317
+ await db.collection("myData").doc("id").set({ key: "value" });
318
+ ```
319
+
320
+ ### Add frontend pages
321
+
322
+ Create `web/settings.html`, use the same pattern, navigate with `App.navigate("/settings.html")`.
323
+
324
+ ### Add Shopify billing
325
+
326
+ Use the `appSubscriptionCreate` GraphQL mutation in your admin API routes.
327
+
328
+ ---
329
+
330
+ ## Firebase Free Tier
331
+
332
+ The Spark (free) plan covers most Shopify apps:
333
+
334
+ | Resource | Free Limit |
335
+ |----------|-----------|
336
+ | Cloud Functions | 2M invocations/month |
337
+ | Firestore reads | 50K/day |
338
+ | Firestore writes | 20K/day |
339
+ | Hosting storage | 10 GB |
340
+ | Hosting transfer | 360 MB/day |
341
+
342
+ Need more? The Blaze plan (pay-as-you-go) costs most apps **under $5/month**.
343
+
344
+ ---
345
+
346
+ ## GDPR Compliance
347
+
348
+ All three mandatory GDPR webhooks are included and handled:
349
+
350
+ | Webhook | Purpose | Status |
351
+ |---------|---------|--------|
352
+ | `customers/data_request` | Export customer data | Handler included (add your logic) |
353
+ | `customers/redact` | Delete customer data | Handler included (add your logic) |
354
+ | `shop/redact` | Delete all shop data | Handler included (add your logic) |
355
+
356
+ These are **required** for Shopify App Store listing.
357
+
358
+ ---
359
+
360
+ ## Troubleshooting
361
+
362
+ | Problem | Solution |
363
+ |---------|----------|
364
+ | "Missing shop parameter" | Set **App URL** in Partner Dashboard to `https://PROJECT_ID.web.app` |
365
+ | "HMAC verification failed" | Check `SHOPIFY_API_SECRET` in `functions/.env` |
366
+ | "Invalid session token" | Verify `data-api-key` in `web/index.html` matches your API key |
367
+ | Functions not receiving requests | Check `firebase.json` rewrites and run `firebase functions:list` |
368
+ | Webhook failures | Must respond 200 within 5 seconds. Check `firebase functions:log` |
369
+
370
+ ---
371
+
372
+ ## Contributing
373
+
374
+ Contributions welcome! Please open an issue or PR.
375
+
376
+ ```bash
377
+ git clone https://github.com/mksd0398/create-shopify-firebase-app.git
378
+ cd create-shopify-firebase-app
379
+ npm install
380
+ npm link # Test locally: create-shopify-firebase-app test-app
381
+ ```
382
+
383
+ ---
384
+
385
+ ## Related
386
+
387
+ - [Shopify App Development](https://shopify.dev/docs/apps) — Official docs
388
+ - [Firebase Cloud Functions](https://firebase.google.com/docs/functions) — Backend runtime
389
+ - [Shopify App Bridge](https://shopify.dev/docs/api/app-bridge) — Embedded app SDK
390
+ - [Shopify Admin GraphQL API](https://shopify.dev/docs/api/admin-graphql) — Store data API
391
+ - [Theme App Extensions](https://shopify.dev/docs/apps/build/online-store/theme-app-extensions) — Storefront blocks
392
+
393
+ ---
394
+
395
+ ## License
396
+
397
+ MIT
398
+
399
+ ---
400
+
401
+ <p align="center">
402
+ <strong>Build Shopify apps with Firebase — serverless, lightweight, and fully yours.</strong><br/>
403
+ <sub>An alternative to the official Remix template for developers who want simplicity and control.</sub>
404
+ </p>
package/bin/create.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * create-shopify-firebase-app
5
+ *
6
+ * Usage:
7
+ * npx create-shopify-firebase-app my-app
8
+ * npm create shopify-firebase-app my-app
9
+ * npx create-shopify-firebase-app (interactive)
10
+ */
11
+
12
+ import { run } from "../lib/index.js";
13
+
14
+ run(process.argv.slice(2)).catch((err) => {
15
+ console.error("\n\x1b[31mError:\x1b[0m", err.message);
16
+ process.exit(1);
17
+ });