Route params in ssr
See original GitHub issueForgive me for opening a new problem, but I did not understand how it is possible to get on the server in the lower levels of components where I will call ServerPrefetch () and receive data in Vieks and transfer data from the router there. Example:
<script>
import { mapState, mapActions } from 'vuex'
export default {
name: 'SearchBar',
serverPrefetch() {
return this.getSearch()
},
mounted() {
if(!this.searchLocation && !this.searchCategory)
this.getSearch()
},
computed: {
...mapState('application', ['viewPort', 'categories']),
...mapState('search', ['searchCategory', 'searchLocation', 'searchLoading'])
},
methods: {
...mapActions('search', ['setSearch']),
getSearch() {
if(this.$route && this.$route.params && (!this.searchCategory || !this.searchLocation))
return this.setSearch({
location: this.$route.params.location ? this.$route.params.location : null,
category: this.$route.params.category ? this.$route.params.category : null
})
else return null
},
toSearch() {
window.location.href = `/search/${
this.searchLocation && this.searchLocation.nameEnLowercase
? this.searchLocation.nameEnLowercase : 'all_cities'
}/${
this.searchCategory && this.searchCategory.translit
? this.searchCategory.translit : 'all_categories'
}`
}
}
}
</script>
I see route params in *.page.server.js contextProps.url but how I can recive this parameters in components in serverPrefetch()
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Implementing SSR in Next.js: Dynamic routing and prefetching
In addition to SSR support, Next.js offers link prefetching and dynamic ... params contains all the route parameters and their values.
Read more >react router server side rendering: How to get route params on ...
I having big time dealing with react-router with parameters. I cannot extract routes params from route on server side to make proper query ......
Read more >Dynamic Routes - Next.js
Dynamic Routes are pages that allow you to add custom params to your URLs. Start creating Dynamic Routes and learn more here.
Read more >Server Side Rendering with route param not working #27596
After building another time with npm run buid:ssr (angular and node), I've got no more issue with the route param. But the origin...
Read more >Route String - vite-plugin-ssr
We can define multiple parameters. // /pages/film.page.route.js // Parameters available at: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
BTW I have full guidance for vue router integration in progress. This will become far more straightforward once I’ve finished
Thanks for sharing; I added your solution to the docs.
Let me know if you have any other question!