getStaticProps incompatible with hybrid AMP dynamic routes
See original GitHub issueBug report
Describe the bug
getStaticProps
receive different params when using AMP hybrid
and dynamic routes.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
1 - Create an hybrid AMP page with dynamic route (for example pages/[...fragments].js
)
2 - add getStaticPaths
and return data ({params: { fragments: ['foo', 'bar'] }}
)
2 - Run npm run dev
3 - add getStaticProps
and console.log(params)
4 - you will get for one page fragments: ['foo', 'bar']
and then { amp: '1' }
Expected behavior
getStaticProps
should receive all dynamic params and in addition amp
Code Sample
export const config = {
amp: 'hybrid',
}
export const getStaticPaths = async () => {
return {
fallback: false,
paths: [{
params: {
fragments: ['foo', 'bar']
},
}],
}
}
export const getStaticProps = async ({ params }: Param) => {
console.log(params)
return {
props: {
fragments: params.fragments,
},
}
}
System information
- Version of Next.js:
9.5.5
Additional context
Somewhat really similar to:
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
getStaticProps incompatible with hybrid AMP dynamic routes
Bug report Describe the bug getStaticProps is being ignored when added onto a page (that has a dynamic route and is AMP hybrid)....
Read more >Advanced Features: Static HTML Export | Next.js
During next build , getStaticProps and getStaticPaths will generate an HTML file for each page in your pages directory (or more for dynamic...
Read more >Next js - AMP hybrid pages return 404 - Stack Overflow
After lots of debugging, I found that AMP is not supported for the hybrid approach in serverless-next , although it working fine AMP-only ......
Read more >Using getStaticProps and getStaticPaths with TypeScript
I'm using the variable name slug to create the dynamic routes, but you could use anything - another common name is id ....
Read more >升级指南 - Next.js
Next.js 9's dynamic routes are automatically configured on Vercel and do not ... AMP Page</h1> } export const config = { amp: true,...
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
Can you check
next@canary
, we merged a fix yesterday.This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.