Skip to content

Commit 12c90ed

Browse files
🏚
1 parent 7b6fe44 commit 12c90ed

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

readme.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [Usage](#usage)
1616
- [Styles](#styles)
1717
- [Optional Components](#optional-components)
18+
- [Private Pages](#private-pages)
1819
- [Next.js Examples](#nextjs-examples)
1920
- [Packages](#packages)
2021
- [Supported Blocks](#supported-blocks)
@@ -68,19 +69,6 @@ export default ({ recordMap }) => (
6869

6970
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.
7071

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-
8472
## Styles
8573

8674
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.
168156

169157
For each of these optional components, make sure you're also importing the relevant third-party CSS if needed ([above](#Styles)).
170158

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+
171172
## Next.js Examples
172173

173174
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

Comments
 (0)