This project is organized into three branches:
production - Production Environment staging - Staging Environment dev - Development Environment
- Retrieve the trivia.ts from repo owner
- Place the file inside the root of
src/assets/<here>
.
# Install dependencies
pnpm i
# Configure environment variables
# There is an `.env.example` in the root directory you can use for reference
cp .env.example .env
# Push the Drizzle schema to the database
pnpm db:push
-
Make sure you have XCode and XCommand Line Tools installed as shown on expo docs.
NOTE: If you just installed XCode, or if you have updated it, you need to open the simulator manually once. Run
npx expo start
in the root dir, and then enterI
to launch Expo Go. After the manual launch, you can runpnpm dev
in the root directory -
Run the following in the
apps/expo
folderpnpm dev:ios
-
Install Android Studio tools as shown on expo docs.
-
Run the following in the
apps/expo
folderpnpm dev:android
-
Ensure the env variables are populated
-
Run the following in the
apps/nextjs
folder:pnpm dev
TIP: It might be easier to run each app in separate terminal windows, so you get the logs from each app separately. This is also required if you want your terminals to be interactive, e.g. to access the Expo QR code. You can run
pnpm --filter expo dev
andpnpm --filter nextjs dev
to run each app in a separate terminal window.
.github
└─ workflows
└─ CI with pnpm cache setup
.vscode
└─ Recommended extensions and settings for VSCode users
apps
├─ auth-proxy
| ├─ Nitro server to proxy OAuth requests in preview deployments
| └─ Uses Auth.js Core
├─ expo
| ├─ Expo SDK 49
| ├─ React Native using React 18
| ├─ Navigation using Expo Router
| ├─ Tailwind using NativeWind
| └─ Typesafe API calls using tRPC
└─ next.js
├─ Next.js 14
├─ React 18
├─ Tailwind CSS
└─ E2E Typesafe API Server & Client
packages
├─ api
| └─ tRPC v11 router definition
├─ auth
| └─ Authentication using next-auth. **NOTE: Only for Next.js app, not Expo**
├─ db
| └─ Typesafe db calls using Drizzle & Planetscale
└─ ui
└─ Start of a UI package for the webapp using shadcn-ui
tooling
├─ eslint
| └─ shared, fine-grained, eslint presets
├─ prettier
| └─ shared prettier configuration
├─ tailwind
| └─ shared tailwind configuration
└─ typescript
└─ shared tsconfig you can extend from
To add a new package, simply run pnpm turbo gen init
in the monorepo root. This will prompt you for a package name as well as if you want to install any dependencies to the new package (of course you can also do this yourself later).
The generator sets up the package.json
, tsconfig.json
and a index.ts
, as well as configures all the necessary configurations for tooling around your package such as formatting, linting and typechecking. When the package is created, you're ready to go build out the package.
-
Create a New Branch
Always create branches from the production branch.
git checkout production git pull origin production git checkout -b id-branch-name
-
Local Development and Testing:
Develop and test the feature locally.
-
Merge to Dev Branch:
Commit changes, switch to the dev branch, and merge the feature branch into dev.
git add . git commit -m "id - commit message" git checkout dev git pull origin dev git merge id-branch-name git push
-
Create Pull Request to Production:
Create a PR pointing to the production branch for code review.
-
Code Review:
Another developer reviews the code changes in the PR. The other developer will either approve the code or request changes. If changes are requested, handle those changes in the created branch and ensure to remerge changes to the dev branch. If PR is approved the approver will update the ticket status to "Deploy To Staging"
-
Merge to Staging Branch:
After passing code review, an admin of the branch merges into the staging branch.
git checkout staging git pull origin staging git merge id-branch-name git push
-
Testing:
Repo Admin will test the new feature, bug fix, improvement, etc... in the staging environment.
-
Staging Approval:
If testing fails, the tester will update the status back to "In Progress" and the developer goes back to step 3. If testing passes, repo admin will update status to "Deploy To Production."
-
Merge to Production Branch:
Merge the branch via PR. Any changes to production MUST be done via approved PRs.
-
If your branch is behind production by more than 1 commit, then sync production to your branch before closing the PR via
git checkout clickup-id-branch-name git pull origin production git merge production
and handle any possible conflicts carefully. and push changes. Once your branch is up to date then close the PR.
-
- Always ensure that secrets are securely stored and retrieved for local development.
- Use meaningful commit messages.
- Collaborate through PRs to maintain code quality and allow for proper code review.
- Regularly update your local branches to avoid conflicts.
- OAuth deployments are now working for preview deployments. Read deployment guide and check out the source to learn more!
- The db package is preconfigured to use PlanetScale and is edge-bound with the database.js driver. If you're using something else, make the necessary modifications to the schema as well as the client and the drizzle config. If you want to switch to non-edge database driver, remove
export const runtime = "edge";
from all pages and api routes.
Note Please note that the Next.js application with tRPC must be deployed in order for the Expo app to communicate with the server in a production environment.
Let's deploy the Next.js application to Vercel. If you've never deployed a Turborepo app there, don't worry, the steps are quite straightforward. You can also read the official Turborepo guide on deploying to Vercel.
-
Create a new project on Vercel, select the
apps/nextjs
folder as the root directory. Vercel's zero-config system should handle all configurations for you. -
Add your
DATABASE_URL
environment variable. -
Done! Your app should successfully deploy. Assign your domain and use that instead of
localhost
for theurl
in the Expo app so that your Expo app can communicate with your backend when you are not in development.
The auth proxy is a Nitro server that proxies OAuth requests in preview deployments. This is required for the Next.js app to be able to authenticate users in preview deployments. The auth proxy is not used for OAuth requests in production deployments. To get it running, it's easiest to use Vercel Edge functions. See the Nitro docs for how to deploy Nitro to Vercel.
Then, there are some environment variables you need to set in order to get OAuth working:
- For the Next.js app, set
AUTH_REDIRECT_PROXY_URL
to the URL of the auth proxy. - For the auth proxy server, set
AUTH_REDIRECT_PROXY_URL
to the same as above, as well asAUTH_DISCORD_ID
,AUTH_DISCORD_SECRET
(or the equivalent for your OAuth provider(s)). Lastly, setAUTH_SECRET
to the same value as in the Next.js app for preview environments.
Read more about the setup in the auth proxy README.
Deploying your Expo application works slightly differently compared to Next.js on the web. Instead of "deploying" your app online, you need to submit production builds of your app to app stores, like Apple App Store and Google Play. You can read the full guide to distributing your app, including best practices, in the Expo docs.
-
Make sure to modify the
getBaseUrl
function to point to your backend's production URL: -
Let's start by setting up EAS Build, which is short for Expo Application Services. The build service helps you create builds of your app, without requiring a full native development setup. The commands below are a summary of Creating your first build.
# Install the EAS CLI pnpm add -g eas-cli # Log in with your Expo account eas login # Configure your Expo app cd apps/expo eas build:configure
-
After the initial setup, you can create your first build. You can build for Android and iOS platforms and use different
eas.json
build profiles to create production builds or development, or test builds. Let's make a production build for iOS.eas build --platform ios --profile production
If you don't specify the
--profile
flag, EAS uses theproduction
profile by default. -
Now that you have your first production build, you can submit this to the stores. EAS Submit can help you send the build to the stores.
eas submit --platform ios --latest
You can also combine build and submit in a single command, using
eas build ... --auto-submit
. -
Before you can get your app in the hands of your users, you'll have to provide additional information to the app stores. This includes screenshots, app information, privacy policies, etc. While still in preview, EAS Metadata can help you with most of this information.
-
Once everything is approved, your users can finally enjoy your app. Let's say you spotted a small typo; you'll have to create a new build, submit it to the stores, and wait for approval before you can resolve this issue. In these cases, you can use EAS Update to quickly send a small bugfix to your users without going through this long process. Let's start by setting up EAS Update.
The steps below summarize the Getting started with EAS Update guide.
# Add the `expo-updates` library to your Expo app cd apps/expo pnpm expo install expo-updates # Configure EAS Update eas update:configure
-
Before we can send out updates to your app, you have to create a new build and submit it to the app stores. For every change that includes native APIs, you have to rebuild the app and submit the update to the app stores. See steps 2 and 3.
-
Now that everything is ready for updates, let's create a new update for
production
builds. With the--auto
flag, EAS Update uses your current git branch name and commit message for this update. See How EAS Update works for more information.cd apps/expo eas update --auto
Your OTA (Over The Air) updates must always follow the app store's rules. You can't change your app's primary functionality without getting app store approval. But this is a fast way to update your app for minor changes and bug fixes.
-
Done! Now that you have created your production build, submitted it to the stores, and installed EAS Update, you are ready for anything!
The stack originates from create-t3-app.
A blog post where I wrote how to migrate a T3 app into this.