What is the limitations of router pages

I find that router pages seem interesting. If I want to create a url pattern like below and make a router page with code answer to that.

https://wixsweden.se/members/profile/

I just created a new router with prefix /members/ and the path[0] will hold profile, so far so good.

I want to post dataa from another site to this router page and get the body posted. Is this possible?

In your docs you write ”Although you can use static data with a router, typically you would use data from your site’s database or an external source. We’ll see where you would write code to retrieve that data a little later.”

How can I get connection to my datasets from the router.js file?

If I want my router to send back a response code 200 and a json formatted message, is this doable?

Hi Andreas,

what you want seems like a use case for Compute Functions. As router pages always respond only to GET requests and with the page content.

To use database in a router page, you would use wix-data module to retrieve the data.

It would seem a good idea to open up for post to router pages, maybe that is compute functions :slight_smile:

What happens if I response with sendmessage function and a 200 status code and some text like ”Thank you” would the whole page gets returned then?

Site will show an error as we do expect a router to return a router response.

ok so what does this function do?

You can not send a response back to the client directly. It instructs Wix to render appropriate status page.

Ok so the message that I can choose to send will be sent to the WIX page and not to the client itself? So what routers do is take care of incoming requests, gather or do stuff with code and redirect or respond with a WIX page?

Any ideas of letting routers handle POSTs and also be setup to answer the client directly? Or maybe that is what compute functions will deliver?

I have three projects that really depend on this and I have to deliver all three before end of september :frowning: Help me use WIX, I don’t want to turn back to WordPress for one project.

Hi Andreas,
let me explain a bit about routers.

the idea is to let the user (that’s you!) control the way a URL is resolved.
for example for dynamic pages, wix has already implemented a router for you, that takes the URL and resolved it to a page based on the fields you bind to that URL pattern when you create a new dynamic page.

but, advanced users may wish to have their own URL resolving logic, and that is where routers come in.

in essence, the router you create can use whatever logic makes sense in your context, as long as the response includes the page you want the URL to resolve to.

for your scenario, it seems you need to get some input from outside your site for the page to display.
so the question is, can your router logic fetch that data from wherever it is, and use it to resolve the URL to a page and pass the data to it?

i.e. instead of POSTing the data to the router, let the router get the data from where it is as part of the resolving logic.

hope it helps…

Ok I think I get it. I think I just have to wait for the compute functions to make this project work :frowning:

Hey jumping in like 2 years later. I was wondering if routers would help my situation. Ive asked on other threads and got told how to open a lightbox, but that wasnt what i kept asking.

If i had a lightbox open based on a dropdown menu selection on a page, could i control what elements of the lightbox are hidden or shown based on which selection in the dropdown menu using a router? Like the choice will open a lightbox no matter what, but what is shown needs to be dependent on which choice is sselected.

I figured that since routers can do that based on which page you are coming from, you could possibly turn a lightbox into a dynamic lightbox this way but im not sure how/if it would work.

Thanks in advance for any help or advice