serverless nextjs config needs official support/documentation
See original GitHub issueBug description
Prisma doesn’t work out of the box with Nextjs and AWS serverless framework. https://github.com/prisma/prisma/issues/6032
@millsp proposed a solution inside the serverless config file: https://github.com/millsp/prisma-serverless-nextjs
# serverless.yml
build:
postBuildCommands:
- PDIR=node_modules/.prisma/client/;
LDIR=.serverless_nextjs/api-lambda/;
if [ "$(ls -A $LDIR)" ]; then
mkdir -p $LDIR$PDIR;
cp "$PDIR"query-engine-rhel-* $LDIR$PDIR;
cp "$PDIR"schema.prisma $LDIR$PDIR;
fi;
- PDIR=node_modules/.prisma/client/;
LDIR=.serverless_nextjs/default-lambda/;
if [ "$(ls -A $LDIR)" ]; then
mkdir -p $LDIR$PDIR;
cp "$PDIR"query-engine-rhel-* $LDIR$PDIR;
cp "$PDIR"schema.prisma $LDIR$PDIR;
fi;
The solution needs official support in prisma generate
or a reference in the prisma docs.
I propose a prisma config like serverless: true
that runs the above script automatically.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Blog - Next.js 8
Next.js 8 introduces Serverless Mode, smaller bundles, performance improvements, and more.
Read more >Serverless Next.js Component - Serverless Framework: Plugins
A zero configuration Next.js 10/11 serverless component for AWS ... The component takes care of all the routing for you so there is...
Read more >Inputs - Serverless Nextjs
Name Type Default Value
domain Array null
bucketName string null
bucketRegion string us‑east‑1
Read more >How Tencent Scales to Millions with Serverless Next.js
Combining the Serverless Services and Next.js Framework, Tencent Online Education team scales to millions and also saving costs by 90%.
Read more >serverless-nextjs-plugin - npm package - Snyk
npm install --save-dev serverless-nextjs-plugin. Out of the box, the plugin won't require any configuration. If you need to override any defaults check this ......
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
this is issue is solved. It doesn’t require these much of of code below postBuildCommands. It just required two lines of code in latest versions (next > 12 and prisma >= 4).
for older version (next 10, 11) (prisma 3.15)
you need to add below line in your next.config.js
target: 'experimental-serverless-trace'
reference issue
@jeremygottfried , I opened a new issue with prisma. But, I may probably solve it myself and post the solution.
But, your raised issue was very valid that it should have a proper document. Such fixes is not a good standard for using any plugin or library.