This is a sample project for demonstrating the ReferenceError: crypto is not defined
issue which happens during a
build for projects those us Gatsby
or Next.js
for SSR
and the installed @primer-io/checkout-web
package's
version is above > 2.x
.
Install the dependencies
npm install
Start the dev server
npm run dev
When it's up and ready you can access the sample project on the http://localhost:3000
. The root page was generated by
the framework itself, the checkout page by us. You can access that on http://localhost:3000/checkout
.
Build the project
npm run build
After a short period of time, the build is going to fail with the error
message: ReferenceError: crypto is not defined
.
In the next.config.js
file I tried to come up with some workarounds, but yet none of the worked.