The Showtime app powered by Expo, Next.js, Storybook and Universal UI.
You'll find included:
- Expo SDK 45 (with Hermes on iOS and Android)
- Next.js 12
- React Native for Web
- TypeScript
- Babel config that works for Expo and Next.js with Reanimated in a monorepo
- Reanimated
- React Native Bottom Sheet
- Tailwind
- Sentry
- Expo Application Services
- Custom Development Client
- Progressive Web App
- SWR
- Storybook
- Turbo
- Solito
Introduction: Universal Design System by Axel Delafosse
Code shared between iOS, Android and Web
cd packages/app
Universal design system
cd packages/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-react-native/src/pages/_app.tsx
cd apps/next-react-native
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
Storybook for React Native
Storybook config: apps/storybook-react-native/.storybook/*
cd apps/storybook-react-native
yarn dev
to start Storybook
Here is a quick overview of the repo.
The monorepo leverages Turbo as it's build system. There are a lot of advantages to Turbo 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/next-react-nativeyarn dev:expo-storybook
runs the dev script for @showtime/storybook-react-nativeyarn dev:next-storybook
runs the dev script for @showtime/next-storybookyarn dev:web
runs both dev scripts for @showtime/next-react-native and @showtime/next-storybookyarn dev:mobile
runs both dev scripts for @showtime/expo and @showtime/storybook-react-native
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/next-react-nativeyarn build:expo-storybook
runs the build script for @showtime/storybook-react-nativeyarn build:next-storybook
runs the build script for @showtime/next-storybook
yarn start:next
runs the start script for @showtime/next-react-native
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/next-react-nativeyarn lint:expo-storybook
runs the lint script for @showtime/storybook-react-nativeyarn lint:next-storybook
runs the lint script for @showtime/next-storybookyarn lint:next-react-native
runs the lint script for @showtime/next-react-native
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-react-native
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 and storybook-react-native apps.
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
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 javascript bundler.
// For iOS
yarn ios -d
// For android
yarn android
- For subsequent developments, we can simple start javascript bundler, no need to build dev client again. Run below command 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: axeldelafosse/expo-next-monorepo-example#1
Magic + WalletConnect
packages/app/components/login.tsx
RudderStack
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-react-native
-
Increment the patch version in the root
package.json
-
Run
yarn update:production
inapps/expo
-
Close and reopen 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
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
- 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
export { Component }
instead ofexport default Component