In your application
Quickstart: Expo
One command sets an Expo application up on Rezin Core: a project for each of your environments, the same tables in each, your settings written the Expo way, and a ready-made client file.
These steps were checked by running rezin init against sample Expo folders and a real API. They were not run on a phone or through an EAS build.
Before you start
- An account, a company and the [
rezintool](/docs/tools/cli), signed in with a personal access token that:- is look and change,
- reaches everything in the company (tick the company, not single projects),
- includes the part Your account and companies, plus Database.
- You are an owner of the company. Only an owner can create projects.
- Your
app.jsonhas ascheme, for example"scheme": "myapp". Sign-in links and provider sign-in use it to open your application.
Run it
In your application's folder:
rezin init
It shows what it is about to do and asks before doing anything:
Expo application "harbor-notes" in .
Company: Harbor Lane
ENVIRONMENT PROJECT WHAT HAPPENS SETTINGS FILE
----------- --------------------------- ------------------------ ----------------
development Harbor Notes (development) a new project is created .env.development
preview Harbor Notes (preview) a new project is created .env.preview
production Harbor Notes (production) a new project is created .env.production
- The environments come from the build profiles in your
eas.json. With noeas.jsonyou getdevelopmentandproduction. Choose your own with--envs development,staging,production. rezin init --dry-runonly shows the plan.--yesskips the question, for scripts.- Each project counts toward your plan. If the company has no room, nothing is created and it says so.
What it writes
| File | What |
|---|---|
.env.<environment> | EXPO_PUBLIC_REZIN_URL, EXPO_PUBLIC_REZIN_PROJECT_ID, EXPO_PUBLIC_REZIN_KEY. Lines already in the file stay |
eas.json | The same three values in each build profile's env. Everything else in the file is kept |
lib/rezin.ts | The client, with the session kept in the device's keychain, and a helper that finishes sign-in links |
rezin/migrations/0001_profiles.sql | A starter table with its access rules. Edit or replace it |
rezin/config.json | Which project each environment is. Commit it |
.gitignore | .env*.local and the backup files are added; nothing is removed |
A file that already exists and would change is copied to <name>.bak-<time> first, and the difference is printed.
No secret key is written anywhere. Only the publishable key goes into your application; it is safe there. A secret key does not belong in a phone app or its environment files. If a server of yours needs one, make it in the console under Connect → Keys and address.
It also:
- applies the migrations in
rezin/migrationsto every environment, so they start with the same tables; - adds
<your scheme>://sign-into each project's allowed sign-in addresses, andhttp://localhost:8081/**to the development project for Expo on the web.
Install the library
rezin init offers to do this. By hand:
npm install https://rezincore.com/docs/downloads/rezincore-client.tgz
npx expo install expo-secure-store expo-linking
Use it
import { useEffect } from 'react';
import { rezin, watchSignInLinks } from '../lib/rezin';
export default function RootLayout() {
useEffect(() => watchSignInLinks(), []); // finishes a sign-in that came back through a link
// ...
}
await rezin.auth.signIn({ email, password });
const profile = await rezin.table('profiles').first({ where: { user_id: session.userId } });
rezin init --example adds a small sign-in screen you can open to check everything is connected.
Types for your tables:
rezin types -p <development project id> -o lib/rezin.types.ts
See the client library for everything it does.
Which environment the application uses
- Running locally (
npx expo start): Expo reads.env.development. A production bundle (npx expo export) reads.env.production. - EAS builds: each build profile uses the
envwritten intoeas.json. - If you keep variables on EAS instead of in
eas.json, set them there yourself, for example:
eas env:set --name EXPO_PUBLIC_REZIN_URL --value https://api.rezincore.com --environment production --visibility plaintext
Sign-in links and Expo Go
Email and password sign-in works everywhere. Sign-in links and provider sign-in come back to <your scheme>://sign-in, which needs a build of your own application (a development build). Expo Go's own address changes with your network, so it cannot be put on a project's list of allowed addresses.
Keep the environments in step
Add a migration file to rezin/migrations, then:
rezin env push development # try it
rezin env diff development production
rezin env push --all # when it is right
See Environments.
Run it again
rezin init is safe to repeat. It links to the projects it made, changes nothing that is already right, and makes no new keys.
Before real users arrive
Mark the production project as production in the console (Connect → Assistants and approvals). A coding assistant then reaches it only on purpose, and what it asks to change there waits for you to approve.