0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-23 20:33:16 -05:00
logto/packages/console/public/get-started/application/react/zh-cn/step2.md

35 lines
901 B
Markdown
Raw Normal View History

---
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>
);
};
```