π¨βπ» Setting up Local Development
T4 App requires Node 20 and a Unix system. We are working towards Windows support so feel free to test it out and report any bug you find on our Discord.
Next.js Environment Variables
Rename .env.example
to .env.local
and add your own values. Everytime you change this file you should run bun install
to scaffold all the necessary environment files.
# Expo & Next.js Setup
PUBLIC_API_URL=http://localhost:8787
PUBLIC_APP_URL=http://localhost:3000
PUBLIC_SUPABASE_ANON_KEY=
PUBLIC_SUPABASE_URL=
PUBLIC_SUPPORT_EMAIL=
PUBLIC_METADATA_NAME="T4 App"
PUBLIC_METADATA_DESCRIPTION="Type-Safe, Full-Stack Starter Kit for React Native + Web."
# Expo Setup
PUBLIC_EAS_OWNER=
PUBLIC_EAS_PROJECT_ID=
# Cloudflare Wrangler Setup
JWT_VERIFICATION_KEY=
DATABASE_ID=
API Environment Variables
This is now automated with the environment variables script so you just need to add the DATABASE_ID
, PUBLIC_APP_URL
and JWT_VERIFICATION_KEY
to the top level .env.local
and then run bun install
to generate the .dev.vars
file.
DATABASE_ID
is the chosen database id as discussed earlier in the guide.APP_URL
is the URL of your Next.js app. For example,http://localhost:3000
.- Get your
JWT_VERIFICATION_KEY
from Supabase (opens in a new tab).
The result is a file called .dev.vars
in /packages/api
with the following environment variables added.
# For preventing CORS errors
APP_URL=
# For Supabase @link https://supabase.com
JWT_VERIFICATION_KEY=
Configure Wrangler.toml
For more info, see the official Cloudflare Wrangler docs (opens in a new tab).
Wrangler is the official CLI tool for Cloudflare Workers.
Replace the account_id
and database_id
with your own values, following our D1 instructions or these ones:
- Go to Cloudflare (opens in a new tab) and create an account.
- Go to "Workers & Pages Overview" and create a new project.
- Configure GitHub integration.
- Configure D1 database bindings with your project.
- do not select the '--experimental-backend' option while in Alpha
- currently this option does not support backups & migrate command fails
- Enter your project details in
wrangler.toml
.
Wranger.toml Example
name = "t4-api"
compatibility_date = "2023-01-01"
send_metrics = false
account_id = "your_account_id"
[[ d1_databases ]]
binding = "DB"
database_name = "production"
database_id = "your_db_id"
Expo
-
Go in your Expo settings (opens in a new tab) to create a new access token.
-
Add the
EXPO_TOKEN
secret to your repository with the token that you retrieved from Expo to allow GitHub Actions to publish your app. -
Create a new project in the Expo projects (opens in a new tab)
-
Add the correct
projectId
to yourapps/expo/app.json
. Update theslug
field to match your project name. Also update theowner
field with your Expo username. -
Update
projectId
,slug
andowner
fallback field inside ofapps/expo/app.config.ts
. -
Setup EAS credentials for your Android and IOS apps by running
eas credentials
in your terminal. Setup the correctandroid.package
andios.bundleIdentifier
inapps/expo/app.json
.