Pass variable to page with route

How can I pass variables to a page in a route? I know there’s $site->visit() and return page(). In Kirby 2 I could add a $data array.
There nothing about that in the Routing docs, either.

That’s how I thought it would work:

  'pattern' => 'foo/(:any)',
    'action'  => function ($bar) {
      $data = [
        "bar" => $bar
      return array("foo", $data);

But it will just display this on the page:

    "bar": "my-url"

See this example:

It works with $page->render().

Ah, cool! Thanks a lot!

Should I add an issue to the Docs repo about this? It’s a bit hidden imo.

Yes, please do, I’ll try to add it tonight.