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

901 B

title subtitle
初始化 LogtoClient 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.

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