Next.js Discord

Discord Forum

Modal Question / Help

Unanswered
Trevor posted this in #help-forum
Open in Discord
I am still learning NextJS (v15) as I come across new things, and this one has definitely stumped me.

I am wondering what kind of approach I would want to take for something like this:

I have a page called games which will maps all of the current matchups using my matchupcard component.
Each matchup maps all of the players, using my playercard component.

Now, when a user clicks on a player, I want it to load player details, using a Modal popup. It will have to fecth some more data for that specific player from my supabase DB. So I was wondering if it would be possible to have it load the Modal using SSR.

This is a good example of what I am looking for, I just cant seem to piece this together:
https://x.com/asidorenko_/status/1725548472839950553

So when a user clicks on a player, it will display the popup modal. I dont want this modal to have a specific page, meaning if they were to refresh the page, it would take them to the homepage for example.

What concepts would I have to use to achieve this? Would it be considered what the title is in the twitter video?:
Modal with parallel routes in Next.js (without intercepting)

I have tried to follow the details and steps from the twitter video but cant seem to get anything to work. If anyone were to have an example of what I am trying to achieve, thet would be great.

Any feedback is appreicated.

Thanks

27 Replies

So you are saying you need a traditional way of rendering a popup modal right? with something like createPortal() ?
Perhaps, thats what it seems to be. I've spent the past couple days trying to wrap my head around all of this. Is that what it would be called? A portal?
If Intercepting route for modal is not what you want, then you just need this https://react.dev/reference/react-dom/createPortal no?
It appears that should work. I guess another thing would be is this possible to do globally? As I will want multiple pages to be able to open this portal.

To gather more data, would it have to use an API or would it be possible to gather it using server side?
but didn't understand your last question
you mean the data to show inside the modal?
Ok sweet. I havn't done anything with a portal before, so I tried watching a quick video on it lol.

So when a user clicks a player, I will need it to grab some more in depth details about that player from my tables in supabase. How would you do this? Just like an API call?
I guess what Im asking, in what approach would you use to grab more data for that portal/modal
yeah, make a request inside the modal to grab data from supabase and render
would you reccomend using an API endpoint or using the supabase client?
supabase client
in your api route, you should be also using supabase right?
I haven't setup anything using an API route yet. Are they protected? So if someone were to just call the API, could they directly grab the data?
Appreciate your help also
I have just my basic pages setup so far using SSR, so all the data loads from the initial load
well, next.js api routes are public by default
why do you think they need to be protected?
In the future, if I were to setup a paywall, would they be able to just access the data through the API?
yeah then you can protect at that moment
Ok, currently I am trying to set it up so you at least have to make an account to be able to access the data (so kind of the same sense). How would I go about this?
Does the supabase client handle that?
well then do you have authentication implemented?
Yes I do have authentication implemented. Sorry I should have stated that
also @Trevor I feel like it's better to close this thread and open new one for your following questions as it's far different from the original question
@James4u also <@141002757040504832> I feel like it's better to close this thread and open new one for your following questions as it's far different from the original question
Ok, ill do some testing with the API setup to see if its protected first as I have the authentication setup. Thanks for your help