Skip to content

Instantly share code, notes, and snippets.

@Hurly77
Created April 23, 2021 02:17
Show Gist options
  • Save Hurly77/e244915ed52392a0622f257516599ec2 to your computer and use it in GitHub Desktop.
Save Hurly77/e244915ed52392a0622f257516599ec2 to your computer and use it in GitHub Desktop.
//as long as we don't attempt to use this in the client side code Next will split this away from the client side render. so the client wont see this import.
import fs from 'fs'
...
export const getStaticProps = async() => {
//normally we would not be able to run the fs.readFile() method but with Next we can actually import this in here and use the same way we would in a node application.
fs.readFileSync()
return {props: {
products: [id: 'p1', title: 'Product 1']
}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment