Skip to content

Commit

Permalink
docs: enhance docs
Browse files Browse the repository at this point in the history
  • Loading branch information
einaralex committed Aug 28, 2024
1 parent 41c053f commit ebba40e
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 2 deletions.
19 changes: 19 additions & 0 deletions apps/developer/docs/packages/SDK/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# @monerium/sdk

A library to interact with Monerium API.

## Example

```tsx
import { MoneriumClient } from '@monerium/sdk';

const monerium = new MoneriumClient({
clientId: '...',
redirectUri: '...',
environment: 'sandbox',
})

await monerium.getAccess();

// Retrieve profiles the client has access to.
await monerium.getProfiles();
```

## References

### default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> **MoneriumProvider**(`params`: \{`children`: `ReactNode`;`clientId`: `string`;`environment`: `'sandbox'`;`redirectUri`: `string`;`redirectUrl`: `string`; \}): `Element`
Place this provider at the root of your application.
Wrap your application with the Monerium provider.

## Parameters

Expand Down
42 changes: 42 additions & 0 deletions apps/developer/docs/packages/sdk-react-provider/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# @monerium/sdk-react-provider

A library to interact with Monerium API with React hooks.

This context provider utilizes React Query for async data fetching and caching.

## Installation

```bash
pnpm add @monerium/sdk-react-provider @tanstack/react-query
```

### Wrap App in Context Provider

Wrap your app in the `QueryClientProvider` React Context Provider and pass a new `QueryClient` instance to the `client` property

Inside the `QueryClientProvider`, wrap your app in the `MoneriumProvider` React Context Provider and pass the auth flow's `clientId`, `redirectUri`, and `environment` configuration.

## Example

```tsx
import { createRoot } from 'react-dom/client';
import { MoneriumProvider } from '@monerium/sdk-react-provider';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

import App from './App';
const rootElement = document.getElementById('root');
const root = createRoot(rootElement);

const queryClient = new QueryClient();

root.render(
<QueryClientProvider client={queryClient}>
<MoneriumProvider
clientId="..."
redirectUri="..."
environment="sandbox"
>
<App />
</MoneriumProvider>
</QueryClientProvider>
);
```

## Provider

- [MoneriumProvider](/docs/packages/sdk-react-provider/functions/MoneriumProvider.md)
Expand Down
45 changes: 45 additions & 0 deletions packages/sdk-react-provider/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
/**
* @packageDocumentation
* A library to interact with Monerium API with React hooks.
*
* This context provider utilizes React Query for async data fetching and caching.
*
* ## Installation
*
* ```bash
* pnpm add @monerium/sdk-react-provider @tanstack/react-query
* ```
*
* ### Wrap App in Context Provider
*
* Wrap your app in the `QueryClientProvider` React Context Provider and pass a new `QueryClient` instance to the `client` property

Check warning on line 15 in packages/sdk-react-provider/src/index.ts

View workflow job for this annotation

GitHub Actions / Build, Test, Lint and Publish

Irregular whitespace not allowed

Check warning on line 15 in packages/sdk-react-provider/src/index.ts

View workflow job for this annotation

GitHub Actions / Build, Test, Lint and Publish

Irregular whitespace not allowed

Check warning on line 15 in packages/sdk-react-provider/src/index.ts

View workflow job for this annotation

GitHub Actions / Build, Test, Lint and Publish

Irregular whitespace not allowed
*
* Inside the `QueryClientProvider`, wrap your app in the `MoneriumProvider` React Context Provider and pass the auth flow's `clientId`, `redirectUri`, and `environment` configuration.
*
* @example
* ```tsx
* import { createRoot } from 'react-dom/client';
* import { MoneriumProvider } from '@monerium/sdk-react-provider';
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
*
* import App from './App';
* const rootElement = document.getElementById('root');
* const root = createRoot(rootElement);
*
* const queryClient = new QueryClient();
*
* root.render(
* <QueryClientProvider client={queryClient}>
* <MoneriumProvider
* clientId="..."
* redirectUri="..."
* environment="sandbox"
* >
* <App />
* </MoneriumProvider>
* </QueryClientProvider>
* );
* ```
*
*/

export * from './lib/provider';
export * from './lib/context';
export * from './lib/hooks';
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-react-provider/src/lib/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MoneriumContext } from './context';
import { AuthorizeParams } from './types';

/**
* Place this provider at the root of your application.
* Wrap your application with the Monerium provider.
* @group Provider
* @param params
* @param params.children - Rest of the application.
Expand Down
21 changes: 21 additions & 0 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/**
* @packageDocumentation
* A library to interact with Monerium API.
*
* @example
* ```tsx
* import { MoneriumClient } from '@monerium/sdk';
*
* const monerium = new MoneriumClient({
* clientId: '...',
* redirectUri: '...',
* environment: 'sandbox',
* })
*
* await monerium.getAccess();
*
* // Retrieve profiles the client has access to.
* await monerium.getProfiles();
* ```
*/

import { MoneriumClient } from './client';
export { default as constants } from './constants';
export * from './types';
Expand Down

0 comments on commit ebba40e

Please sign in to comment.