@logto/react 1.0.0-beta.0 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +8 -96
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  [![Build Status](https://github.com/logto-io/js/actions/workflows/main.yml/badge.svg)](https://github.com/logto-io/js/actions/workflows/main.yml)
4
4
  [![Codecov](https://img.shields.io/codecov/c/github/logto-io/js)](https://app.codecov.io/gh/logto-io/js?branch=master)
5
5
 
6
- The Logto React SDK written in TypeScript. Check out our [integration guide](https://docs.logto.io/integrate-sdk/react) or [docs](https://docs.logto.io/sdk/react) for more information.
6
+ The Logto React SDK written in TypeScript. Check out our [integration guide](https://docs.logto.io/docs/recipes/integrate-logto/react) or [docs](https://docs.logto.io/sdk/JavaScript/react/) for more information.
7
7
 
8
- We also provide [集成指南](https://docs.logto.io/zh-cn/integrate-sdk/react) and [文档](https://docs.logto.io/zh-cn/sdk/react) in Simplified Chinese.
8
+ We also provide [集成指南](https://docs.logto.io/zh-cn/docs/recipes/integrate-logto/react/) and [文档](https://docs.logto.io/zh-cn/sdk/JavaScript/react/) in Simplified Chinese.
9
9
 
10
10
  ## Installation
11
11
 
@@ -24,109 +24,21 @@ yarn add @logto/react
24
24
  ### Using pnpm
25
25
 
26
26
  ```bash
27
- pnpm install @logto/react
27
+ pnpm add @logto/react
28
28
  ```
29
29
 
30
- ### Using CDN
30
+ ## Get sample
31
31
 
32
- ```bash
33
- <script src="https://logto.io/js/logto-sdk-react/0.1.0/logto-sdk-react.production.js" />
34
- ```
35
-
36
- ## Get Started
37
-
38
- A sample project with the following code snippets can be found at [React Sample](https://github.com/logto-io/js/tree/master/packages/react-sample)
39
-
40
- Check out the source code and try it yourself. (We use [pnpm](https://pnpm.io/) for package management)
41
-
42
- ```bash
43
- pnpm i && pnpm start
44
- ```
45
-
46
- ### Initiate LogtoClient
47
-
48
- ```tsx
49
- import { LogtoProvider, LogtoConfig } from '@logto/react';
50
-
51
- const App = () => {
52
- const config: LogtoConfig = {
53
- clientId: 'foo',
54
- endpoint: 'https://your-endpoint-domain.com'
55
- };
56
-
57
- return (
58
- <BrowserRouter>
59
- <LogtoProvider config={config}>
60
- <Routes>
61
- <Route path="/" element={<Home />} />
62
- <Route path="/callback" element={<Callback />} />
63
- <Route
64
- path="/protected-resource"
65
- element={
66
- <RequireAuth>
67
- <ProtectedResource />
68
- </RequireAuth>
69
- }
70
- />
71
- </Routes>
72
- </LogtoProvider>
73
- </BrowserRouter>
74
- );
75
- };
76
- ```
77
-
78
- ### Setup your sign-in
32
+ A sample project can be found at [React Sample](https://github.com/logto-io/js/tree/master/packages/react-sample)
79
33
 
80
- ```tsx
81
- import { useLogto } from '@logto/react';
34
+ Check out the source code and try it with ease.
82
35
 
83
- const SignInButton = () => {
84
- const { signIn } = useLogto();
85
- const redirectUrl = window.location.origin + '/callback';
86
-
87
- return <button onClick={() => signIn(redirectUrl)}>Sign In</button>;
88
- };
89
-
90
- export default SignInButton;
91
- ```
92
-
93
- ### Retrieve Auth Status
94
-
95
- ```tsx
96
- import { useLogto } from '@logto/react';
97
-
98
- const App = () => {
99
- const { isAuthenticated, signIn } = useLogto();
100
-
101
- if !(isAuthenticated) {
102
- return <SignInButton />
103
- }
104
-
105
- return <>
106
- <AppContent />
107
- <SignOutButton />
108
- </>
109
- };
110
36
  ```
111
-
112
- ### Sign out
113
-
114
- ```tsx
115
-
116
- import { useLogto } from '@logto/react';
117
-
118
- const SignOutButton = () => {
119
- const { signOut } = useLogto();
120
- const postLogoutRedirectUri = window.location.origin;
121
-
122
- return <button onClick={() => signOut(postLogoutRedirectUri)}>Sign out</button>;
123
- };
124
-
125
- export default SignOutButton;
37
+ pnpm i && pnpm start
126
38
  ```
127
39
 
128
40
  ## Resources
129
41
 
130
42
  [![Website](https://img.shields.io/badge/website-logto.io-8262F8.svg)](https://logto.io/)
131
- [![Docs](https://img.shields.io/badge/docs-logto.io-green.svg)](https://docs.logto.io/docs/sdk/swift/)
43
+ [![Docs](https://img.shields.io/badge/docs-logto.io-green.svg)](https://docs.logto.io/sdk/JavaScript/react/)
132
44
  [![Discord](https://img.shields.io/discord/965845662535147551?logo=discord&logoColor=ffffff&color=7389D8&cacheSeconds=600)](https://discord.gg/UEPaF3j5e6)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/react",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.2",
4
4
  "source": "./src/index.ts",
5
5
  "main": "./lib/index.js",
6
6
  "exports": {
@@ -29,7 +29,7 @@
29
29
  "prepack": "pnpm test"
30
30
  },
31
31
  "dependencies": {
32
- "@logto/browser": "^1.0.0-beta.0",
32
+ "@logto/browser": "^1.0.0-beta.2",
33
33
  "@silverhand/essentials": "^1.1.6"
34
34
  },
35
35
  "devDependencies": {
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "f0f78e6f0b97174de98588b35d1d12c8396206ba"
68
+ "gitHead": "212891497b04e3a5fd6b24bbbeec227dfec8ae53"
69
69
  }