transitive-bullshit / nextjs-notion-starter-kit

Deploy your own Notion-powered website in minutes with Next.js and Vercel.
https://transitivebullsh.it/nextjs-notion-starter-kit
MIT License
6.16k stars 5.23k forks source link

Limit fetch to teamspace or rootNotionPageId children #571

Open drewatdrawn opened 10 months ago

drewatdrawn commented 10 months ago

Description

I have multiple team spaces used for different clients that I am building out to individual sites. I frequently hit rate limits and can't publish to Vercel because the build process queries all blocks for all teamspaces in my notion account.

It would be great of the rootNotionPageId specified in the config was used as the parent from which the queries happened so as to avoid overfetching.

Is there another way I can limit fetching to only a single teamspace?

transitive-bullshit commented 10 months ago

Have you tried rootNotionSpaceId?

drewatdrawn commented 10 months ago

I have, I had the same overfetching and rate limiting issues.

drewatdrawn commented 10 months ago

I tried experimenting with different workspace / teamspace configurations in Notion to get more information on the overfetching issue. If I create a new workspace and duplicate my content into that workspace, there are no problems (this makes sense, there are no other teamspaces to overfetch into). This would be fine but Notion's paid plan doesn't span workspaces, so I am limited to 1000 blocks if I add collaborators to the new workspace.

If I create a new teamspace in my current workspace and it contains only the root Notion page I want (and its children), I still have the overfetching issue. I can see from the pages queried in the console log in my terminal that pages outside of the teamspace are being referenced.

This happens whether or not I enable the rootNotionSpaceId in the site.config.ts file. I did notice that the rootNotionSpaceId is the same regardless of which teamspace my rootNotionPageId is in, but does change if I switch workspaces. The rootNotionSpaceId seems tied to the workspace, not the teamspace.

drewatdrawn commented 10 months ago

@transitive-bullshit any other ideas on how to limit fetching here? Is that how the rootNotionSpaceId is intended to work? Any insight greatly appreciated! This starter kit is fantastic - hoping I can work out the fetching issue. The rate limiting timeout is a bummer.