This tutorial walks you through configuring environments, enabling billing, and connecting TikTok and Instagram using native OAuth.
-
apps/web/.env
- ENV=development|staging|production
- PUBLIC_BASE_URL=your web base URL (e.g. http://localhost:5173 or prod domain)
- DATABASE_URL=Neon connection string
- AUTH_SECRET=any random string
- STRIPE_SECRET_KEY=sk_live_or_test
- STRIPE_WEBHOOK_SECRET=optional
- TIKTOK_CLIENT_KEY= / TIKTOK_CLIENT_SECRET=
- TIKTOK_REDIRECT_URI_DEV/STAGING/PROD=http(s):///api/tiktok/auth/callback
- INSTAGRAM_CLIENT_ID= / INSTAGRAM_CLIENT_SECRET= / INSTAGRAM_REDIRECT_URI=
- APPLE_IAP_SHARED_SECRET=
- MOBILE_OAUTH_CLOSE_URL=bookmarked://oauth-close (deep link to close in-app browser)
-
apps/mobile/.env
- EXPO_PUBLIC_ENV=development|staging|production
- EXPO_PUBLIC_BASE_URL=http(s)://your web base URL
- EXPO_PUBLIC_IOS_PRODUCT_IDS=com.app.pro.monthly,com.app.pro.yearly
- EXPO_PUBLIC_STRIPE_PRICE_ID=price_xxx
- Create a Product and a recurring Price in Stripe Dashboard.
- Set STRIPE_SECRET_KEY in apps/web/.env.
- Put the Price ID in apps/mobile/.env as EXPO_PUBLIC_STRIPE_PRICE_ID.
- The mobile Subscription screen calls /api/billing/stripe/checkout with the priceId and opens Checkout in the browser.
- In App Store Connect, create Auto‑renewable Subscription(s) and note product IDs.
- Put product IDs in apps/mobile/.env as EXPO_PUBLIC_IOS_PRODUCT_IDS (comma‑separated).
- Set APPLE_IAP_SHARED_SECRET in apps/web/.env.
- After a purchase, the app posts the iOS receipt to /api/billing/ios/validate. The server verifies receipt with Apple and stores entitlement.
- Create a TikTok app, set client key/secret in apps/web/.env.
- Set redirect URIs to /api/tiktok/auth/callback for each environment.
- MOBILE_OAUTH_CLOSE_URL allows the callback to 302 deep link back into the app (bookmarked://oauth-close).
- In Profile screen, "Connect TikTok" calls /api/tiktok/auth/start and opens the authorize URL natively.
- Create an Instagram app (Basic Display API), obtain client id/secret.
- Set INSTAGRAM_CLIENT_ID/SECRET and INSTAGRAM_REDIRECT_URI in apps/web/.env.
- Profile screen "Connect Instagram" uses /api/instagram/auth/start and callback stores the long‑lived token.
Configure your app scheme (e.g., bookmarked://) in your Expo/Native config so that MOBILE_OAUTH_CLOSE_URL can close the in‑app browser upon successful callback.
- Web: cd apps/web && npm run dev
- Mobile: cd apps/mobile && npx expo start