You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a Nextjs project, however it is OSS that will be used locally on machine so I have opted to use lowdb as a database since it's easy to use and perfect for my requirements
On one of my pages, I use getStaticProps to read in data, and pass it to the props of the component. Works perfectly
What I need to do though is have a component that runs on every route and performs a similar query on the database to get the number of users.
If the user array in the database is empty, I want to make sure the users can only access /pages/setup/*. If there are users, then I want to make sure they can only access /pages/* and not /pages/setup/*.
How can I achieve this? I can't use the above function since it only runs on pages.
Any suggestions?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I've got a Nextjs project, however it is OSS that will be used locally on machine so I have opted to use lowdb as a database since it's easy to use and perfect for my requirements
On one of my pages, I use
getStaticProps
to read in data, and pass it to the props of the component. Works perfectlyWhat I need to do though is have a component that runs on every route and performs a similar query on the database to get the number of users.
If the user array in the database is empty, I want to make sure the users can only access
/pages/setup/*
. If there are users, then I want to make sure they can only access/pages/*
and not/pages/setup/*
.How can I achieve this? I can't use the above function since it only runs on pages.
Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions