The Showtime app powered by Expo, Next.js, Storybook and Universal UI.
You'll find included:
- Expo SDK 48 (with Hermes on iOS and Android)
- Next.js 13
- React Native for Web
- TypeScript
- Reanimated (with SWC plugin for Next.js)
- React Native Bottom Sheet
- Tailwind
- Sentry
- SWR
- Storybook
- Turborepo
- Solito
- Expo Application Services
- Custom Development Client
- Progressive Web App (work in progress)
cp apps/expo/.env.development apps/next/.env
then ask the team if the env is correct
yarn
yarn dev:next
Introduction: How to build a great universal design system by Axel Delafosse
Code shared between iOS, Android and Web
cd packages/app
Universal design system
cd packages/design-system
Read more about the design system.
React Native
Expo entrypoint: apps/expo/App.tsx
cd apps/expo
yarn dev
to start the development client (iOS and Android app with Expo)
Web
Next.js entrypoint: apps/next/src/pages/_app.tsx
cd apps/next
yarn dev
to start the web app
Storybook for Web (using React Native for Web)
Storybook config: apps/storybook-react/.storybook/*
cd apps/storybook-react
yarn dev
to start Storybook
You can create a development client in local or in the cloud.
- We're using expo dev client for development builds which allows us to add custom/third party native libraries while preserving the expo like developer experience. Read more about custom dev clients here
- You only need to build and install custom dev client in below cases.
- If you don't have it installed on your phone or simulator
- If you make any changes on native side or add a new native library
- To install dev client, plug your device and run below commands. This will install the dev client and start the Metro bundler.
// For iOS
yarn ios -d
// For android
yarn android
- For subsequent developments, we can simply start the Metro bundler, no need to build dev client again. Run the command below to start the bundler.
yarn dev:expo
❗️ The yarn script commands are from within the @showtime/expo application ❗️
Plug your device and build the app with Expo CLI:
yarn ios -d
yarn android -d
iOS: if yarn ios -d
doesn't detect your iPhone, make sure that you have compatible
Xcode and iOS versions.
Android: if you are on a Mac M1, please install the following JDK:
curl -s "https://get.sdkman.io" | bash
sdk install java 11.0.14-zulu
Use Expo Application Services to build the app:
yarn build:development
This is useful if you want to build the iOS app without a Mac, for example.
React Native for Web + Tailwind
packages/design-system/*
- Design system on Figma
- Learn more: universal design system
Note that we use custom utilities for the fonts to use
capsize
. It's applying negativemargin-top
andmargin-bottom
so you can't use those on<Text>
directly. Prefer using a separator<View tw="h-2" />
instead of<Text tw="mt-2" />
or<Text tw="mb-2" />
for example.
SWR
SWRConfig
inapps/expo/App.tsx
andapps/next/src/pages/_app.tsx
SWR + axios
axiosAPI
inpackages/app/lib/axios.ts
useSWR
hooks likeconst { data, error } = useSWR([url], url => axios({ url, method: 'GET', unmountSignal }))
packages/app/hooks/use-user.ts
React Navigation + Next.js Router
packages/app/navigation/*
- Learn more: https://github.com/nandorojo/solito
// TODO:
Magic + WalletConnect
packages/app/components/login.tsx
Amplitude
Waldo + QA Wolf
Vercel + Expo
GitHub Actions
- ESLint:
.github/workflows/lint.yml
- Expo PR Previews
.github/workflows/expo-preview.yml
- Expo Storybook PR Preview
.github/workflows/expo-storybook-preview.yml
- Expo Staging
.github/workflows/expo-preview.yml
- Expo Production
.github/workflows/expo-preview.yml
- Chromatic Push
.github/workflows/chromatic.yml
Using dotenv
for the Expo app. Next.js is automatically picking up the .env.local
file.
.env.development
+.env.staging
+.env.production
inapps/expo
.env
inapps/next
-
Increment the patch version in the root
package.json
-
Run
yarn update:production
inapps/expo
-
Close and re-open the production app twice to check the new update
-
Increment the major version in the root
package.json
-
Run
yarn deploy:production
inapps/expo
-
Submit the new build for review on TestFlight and Google Play
CI/CD with Vercel for PR previews + GitHub Actions via /promote
Slack command
You can use the /promote frontend
Slack command to promote from staging to production.
Use /promote frontend major
to force a major update (e.g. when you want to force a new native build). Otherwise the version will be incremented automatically and an OTA update will be done if we don't require a new native build.
Pro tip: you can add tw
to Tailwind CSS: Class Attributes
VS Code extension setting to get IntelliSense working.
Pro tip: Ignore a list of commits within git-blame
by default on version >2.23
git config blame.ignoreRevsFile .git-blame-ignore-revs
Here is a quick overview of the repo.
The monorepo leverages Turborepo as it's build system. There are a lot of advantages to Turborepo but two deciding factors were
- Faster, incremental builds
- Cloud caching, managed by Vercel
Turbo pipelines are configured within the root directory package.json and can be ran through yarn scripts.
yarn dev
runs the dev script for every applicationyarn dev:expo
runs the dev script for @showtime/expoyarn dev:next
runs the dev script for @showtime/nextyarn dev:next-storybook
runs the dev script for @showtime/next-storybookyarn dev:web
runs both dev scripts for @showtime/next and @showtime/next-storybookyarn dev:mobile
runs both dev scripts for @showtime/expo
yarn build
runs the build script for every applicationyarn build:expo
runs the build script for @showtime/expoyarn build:next
runs the build script for @showtime/nextyarn build:next-storybook
runs the build script for @showtime/next-storybook
yarn start:next
runs the start script for @showtime/next
yarn lint
runs the lint script for every applicationyarn lint:expo
runs the lint script for @showtime/expoyarn lint:next
runs the lint script for @showtime/nextyarn lint:next-storybook
runs the lint script for @showtime/next-storybookyarn lint:next
runs the lint script for @showtime/next
The formatting rules are the ones from prettier/recommended
. The actual formatting is done via eslint
.
To get formatting on save in VS Code, install the eslint
extension and add the following setting:
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
yarn turbo:graph
generates the current task graph for all applicationyarn turbo:graph:next
generates the current task graph for @showtime/next
clean
removes all monorepo node_modules and clears the turbo cacheclean:turbo
clears the turbo cacheclean:node-modules
removes all node_modulesclean:native
runs yarn clean and removes android, iOS folders from expo.
Turbo can use a technique known as Remote Caching to share cache artifacts across machines for an additional speed boost.
Link your local turbo project to the remote cache through Vercel
npx turbo login
npx turbo link
To verify, build and delete your local turbo cache with:
- Run any build locally
- Clear the turbo cache
yarn clean:turbo
- Then run the same build again. If things are working properly, turbo should not execute tasks locally
If Vercel is not deploying after updating or adding a patch package, you need to click on "Redeploy" on Vercel and don’t select "Use the same cache". Most of the time, it is a cache issue.
- Don't add any package here
- Don't add any package here
- You can use SVGR to generate the icons component from the
.svg
files:npx @svgr/cli --icon --replace-attr-values "#000={props.color},#fff={props.color},#FFF={props.color}" --ignore-existing --native --typescript -d . .
and then you can programmatically change the color thanks tofill={props.color}
for example.
- Add all the React Native and universal packages here
- Add the web-only packages here
- Filenames: lowercase and separated by dashes
- Prefer absolute imports
- Avoid coding in the
index.tsx
file, create a new file and export it from theindex.ts
file export { Component }
instead ofexport default Component