|
15 | 15 | - [Usage](#usage)
|
16 | 16 | - [Styles](#styles)
|
17 | 17 | - [Optional Components](#optional-components)
|
| 18 | +- [Private Pages](#private-pages) |
18 | 19 | - [Next.js Examples](#nextjs-examples)
|
19 | 20 | - [Packages](#packages)
|
20 | 21 | - [Supported Blocks](#supported-blocks)
|
@@ -68,19 +69,6 @@ export default ({ recordMap }) => (
|
68 | 69 |
|
69 | 70 | Note: for heavier blocks, you'll have to opt into using them via `NotionRenderer.components`. These are not included in the default `NotionRenderer` export because they're too heavyweight for a lot of use cases.
|
70 | 71 |
|
71 |
| -## Private Pages |
72 |
| - |
73 |
| -You may optionally pass an `authToken` and `activeUser` to the API if you want to access private Notion pages. Both can be retrieved from your web browser. Once you are viewing your workpace, open your Development Tools > Application > Cookie > and Copy/Paste the `token_v2` and `notion_user_id`. Respectively, activeUser: notion_user_id, authToken: token_v2. |
74 |
| - |
75 |
| -Here's a quick code snippet for the client usage when implementing process env for tokens: |
76 |
| -```tsx |
77 |
| -const notion = new NotionAPI({ |
78 |
| - activeUser: process.env.NOTION_ACTIVE_USER, |
79 |
| - authToken: process.env.NOTION_TOKEN_V2 |
80 |
| - }) |
81 |
| -``` |
82 |
| -If issue arises where the pageId is not found, restart your local host instance. |
83 |
| - |
84 | 72 | ## Styles
|
85 | 73 |
|
86 | 74 | You'll need to import some CSS styles as well. If you're using Next.js, we recommend you place these imports at the top of `pages/_app.js`:
|
@@ -168,6 +156,19 @@ For `Equation` support, you'll need to import the katex CSS styles.
|
168 | 156 |
|
169 | 157 | For each of these optional components, make sure you're also importing the relevant third-party CSS if needed ([above](#Styles)).
|
170 | 158 |
|
| 159 | +## Private Pages |
| 160 | + |
| 161 | +You may optionally pass an `authToken` and `activeUser` to the API if you want to access private Notion pages. Both can be retrieved from your web browser. Once you are viewing your workpace, open your Development Tools > Application > Cookie > and Copy the `token_v2` and `notion_user_id`. Respectively, activeUser: notion_user_id, authToken: token_v2. |
| 162 | + |
| 163 | +```tsx |
| 164 | +const notion = new NotionAPI({ |
| 165 | + activeUser: process.env.NOTION_ACTIVE_USER, |
| 166 | + authToken: process.env.NOTION_TOKEN_V2 |
| 167 | +}) |
| 168 | +``` |
| 169 | + |
| 170 | +Note that this is not the same as the API token provided by the official Notion API since `notion-client` uses the unofficial Notion API (which is what all Notion apps use). |
| 171 | + |
171 | 172 | ## Next.js Examples
|
172 | 173 |
|
173 | 174 | Here's a [minimal Next.js example project](./examples/minimal) with the most important code in [`pages/[pageId].tsx`](./examples/minimal/pages/%5BpageId%5D.tsx) and [`components/NotionPage.tsx`](./examples/minimal/components/NotionPage.tsx). You can view this example [live on Vercel](https://react-notion-x-minimal-demo.transitivebullsh.it).
|
|
0 commit comments