question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getStaticProps incompatible with hybrid AMP dynamic routes

See original GitHub issue

Bug 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
timneutkenscommented, Oct 16, 2020

Can you check next@canary, we merged a fix yesterday.

0reactions
balazsorban44commented, Jan 29, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found