mirror of
https://github.com/logto-io/logto.git
synced 2024-12-23 20:33:16 -05:00
35 lines
901 B
Markdown
35 lines
901 B
Markdown
|
---
|
||
|
title: 初始化 LogtoClient
|
||
|
subtitle: 1 step | Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
||
|
---
|
||
|
Add the following code to your main html file. You may need client ID and authorization domain.
|
||
|
|
||
|
```typescript
|
||
|
import { LogtoProvider, LogtoConfig } from '@logto/react';
|
||
|
import React from 'react';
|
||
|
|
||
|
...
|
||
|
|
||
|
const App = () => {
|
||
|
const config: LogtoConfig = { clientId: 'foo', endpoint: 'https://your-endpoint-domain.com' }
|
||
|
|
||
|
return (
|
||
|
<BrowserRouter>
|
||
|
<LogtoProvider config={config}>
|
||
|
<Routes>
|
||
|
<Route path="/" element={<Home />} />
|
||
|
<Route path="/callback" element={<Callback />} />
|
||
|
<Route
|
||
|
path="/protected-resource"
|
||
|
element={
|
||
|
<RequireAuth>
|
||
|
<ProtectedResource />
|
||
|
</RequireAuth>
|
||
|
}
|
||
|
/>
|
||
|
</Routes>
|
||
|
</LogtoProvider>
|
||
|
</BrowserRouter>
|
||
|
);
|
||
|
};
|
||
|
```
|