I'm learning nextJS and trying to use dynamic routes with a catch all route. However I'm running into a basic problem, I'm not sure how to supply the data as an array in getStaticPaths.
This is my current code:
import Link from 'next/link'
function test({ variable }) {
return (
<>
<div>
<h1>{variable.var}</h1>
<Link href="/"><a>← Back</a></Link>
</div>
</>
)
}
export async function getStaticProps({ params }) {
const variable = params.variable
return {
props: {
variable,
},
}
}
export async function getStaticPaths() {
return {
fallback: false,
paths: [
{
params: {
variable: 'testi'
}
},
]
}
}
export default test
And i'm getting the error:
Error: A required parameter (variable) was not provided as an array in getStaticPaths for /test/[...variable]
Any ideas?
Edit: Forgot to add, my current file name is [...variable].js