Comments (8)
Honestly, that’s a damn good question. Vercel themselves say that bundling everything into a single endpoint is an anti-pattern. I can see why, because file size should be absolutely minimized for both serverless functions and edge functions. But yeah, it does seem like we could reduce the amount of cold starts if we only had one handler for sure.
This will become more complex once Payload further reduces its bundle size, however. The actual functions will need to be extremely small and each designed specifically for their individual task. We are making progress towards this and it won’t be long until hopefully everything will be on edge functions where cold starts won’t be a problem.
I wish we could use app route handlers, but unfortunately the API is so significantly different from express-like request and responses that a lot of the stuff we use, passport included, is 0% compatible.
I smashed my head against the wall for a good two weeks, trying to fit all of this stuff into App route handlers, rather than continuing to use the pages/api folder but I failed big time. Maybe in the future we can get that to work as well. Here’s hoping!
from next-payload.
Thanks for the insight! How will edge functions improve cold starts? Based on the Vite bundler poc I thought that start time is most dependent on config complexity which poses a bottleneck in every environment. Reducing bundle size always helps though ^^
Haven't used route handlers myself, but did bump on similar issues with Deno. Could next-connect be the missing piece?
from next-payload.
Edge functions are fundamentally different in how they are "spun up" when compared to serverless functions. A serverless function is basically just a tiny VM that needs to boot up before executing a script, but edge functions are literally just scripts that get executed.
I am sure I'm glossing over some things and not 100% correct here but supposedly edge functions almost entirely avoid cold starts, which is the big thing that I'm interested in there.
Also - - re: next-connect
, I've looked into that deeply and have even opened up an issue:
We'll see if they add route handler support. That would be great if they did!
from next-payload.
Played a little with it and got the basics working. Next up is wrapping express in a proxy and checking which methods payload actually uses.
from next-payload.
@thgh i have a bit of experience shoehorning things into route handlers. Let me know if you want to collaborate on this.
from next-payload.
@mattddean perfect! I will create a PR later today on the next-connect repo. Would be cool if someone can poke holes in it.
from next-payload.
@mattddean ^ here it is, do you think this approach could work?
from next-payload.
Hi all, this repo will soon be archived because it's been merged into the main Payload repo here: https://github.com/payloadcms/payload/tree/main/packages/next. Payload 3.0 ships with native support for Next.js and is currently out in beta here: https://github.com/payloadcms/payload-3.0-demo. I'm going to close this issue now but feel free to keep the conversation going either as a GitHub Discussion or on Discord. If think issue persists, feel free to open a new ticket on either the demo repo or the monorepo with the 3.x-beta
label, and be sure to include a reproduction so we can fix it faster.
from next-payload.
Related Issues (20)
- Broken with Next.js 14 HOT 10
- Local File Upload Path Mismatch? HOT 4
- Warning: ToastContainer HOT 2
- getPayload is not a function / req.payload is a Promise? HOT 3
- Payload CMS overrides styled-component GlobalStyles HOT 1
- App crashes with postgresql HOT 2
- Unable to set up with postgres on 13.5.6 (works with mongodb) HOT 1
- Cannot find module '../payload/payload.config.ts'
- API Key: You are not allowed to perform this action. HOT 1
- `Error [ERR_REQUIRE_ESM]: require() of ES Module` error when using component in /pages instead of /app folder HOT 4
- Custom views don't work HOT 2
- `getPayloadClient()` fails in server actions HOT 2
- Builds dont work with next14 HOT 6
- Status 500 error with vercel deploy (next14) HOT 2
- Unexpected handler pages/api/[collection]/lib/worker.js HOT 1
- Can't login '/admin' after creating initial admin account on '/admin' page (Next.JS 14 with next-payload) HOT 4
- Incompatability with lexical editor HOT 1
- Unexpected handler pages/api/[collection]/lib/worker.js in next-payload HOT 5
- `loadConfig is not a function` when running `next-payload build` HOT 2
- Full restart required for changes to apply correctly HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-payload.