Skip to content

Exporting a page with path param as a dynamic route #639

Answered by bitspittle
NikSatyr asked this question in Q&A
Discussion options

You must be logged in to vote

Dynamic routes can only work with static hosts that support rewrites. For example, if you're using firebase, you can add the following rewrite:

"hosting": {
  // Serves index.html for requests to files or directories that do not exist
  "rewrites": [ {
    "source": "**",
    "destination": "/index.html"
  } ]
}

If this isn't available to you, another option is to manually generate pages for certain routes in your build script:

kobweb {
  app {
    export {
      addExtraRoute("/blog/how-to")
      addExtraRoute("/blog/kobweb")
    }
  }
}

Of course, you can always manually just create placeholder pages which delegate to some common composable, as well:

// components/sections/BlogPage.kt

i…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@NikSatyr
Comment options

@bitspittle
Comment options

Answer selected by NikSatyr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants