Skip to content

Commit

Permalink
release: v0.1.0 (#19)
Browse files Browse the repository at this point in the history
* release: v0.1.0

* chore: update readme

* fix: fix sample code

fix sample code

* chore: update readme

---------

Co-authored-by: simeng-li <simeng@silverhand.io>
  • Loading branch information
gao-sun and simeng-li authored Feb 23, 2024
1 parent 97b49dd commit f5112ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ The monorepo for Logto React Native (Expo) SDK and sample.
## Installation

```bash
npm install @logto/rn --save
npm install @logto/rn
npm install expo-crypto expo-secure-store expo-web-browser @react-native-async-storage/async-storage
```

The `@logto/rn` package is the SDK for Logto. The remaining packages are its peer dependencies. They couldn't be listed as direct dependencies because the Expo CLI requires that all dependencies for native modules be installed directly within the root project's package.json.
The `@logto/rn` package is the SDK for Logto. The remaining packages are its peer dependencies. They couldn't be listed as direct dependencies because the Expo CLI requires that all dependencies for native modules be installed directly within the root project's `package.json`.

You could also use other package managers such as `yarn` or `pnpm`.

## Configuration

To make the redirect URI deep link work, you need to configure the `scheme` in the `app.json` file.

e.g. In the `@logto/rn-sample` we use `io.logto://callback` as the callback URL.
For instance, in the `@logto/rn-sample` we use `io.logto://callback` as the callback URL.

```json
{
Expand All @@ -44,21 +44,27 @@ e.g. In the `@logto/rn-sample` we use `io.logto://callback` as the callback URL.
```tsx
import { LogtoProvider, useLogto } from "@logto/rn";

const App = () => {
// Use `useLogto()` hook to sign in and sign out
const Content = () => {
const { signIn, signOut, isAuthenticated } = useLogto();

return isAuthenticated ? (
<Button title="Sign Out" onPress={signOut} />
) : (
<Button title="Sign In" onPress={async () => signIn(redirectUri)} />
);
};

// Wrap your page component with `LogtoProvider`
const App = () => {
const logtoConfig = {
appId: "YOUR_APP",
endpoint: "YOUR_LOGTO_ENDPOINT",
};

return (
<LogtoProvider config={logtoConfig}>
{isAuthenticated ? (
<Button title="Sign Out" onPress={signOut} />
) : (
<Button title="Sign In" onPress={async () => signIn(redirectUri)} />
)}
<Content />
</LogtoProvider>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/rn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "0.1.0-beta.0",
"version": "0.1.0",
"type": "module",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down

0 comments on commit f5112ac

Please sign in to comment.