server action without declaring `export const runtime = 'edge';`
is there a way to make the server action be served on a separate URL & not in the page it's used in?
35 Replies
@Firu did you manage to solve this issue? If so, how?
Wow this has been a very long time
Nope, I gave up on Server Actions
I'm using plain ole Route Handlers or a separate backend
At this point, I will have to give up too
on Cloudflare Workers still
yeah, it's a mess
the "magic" really ruins the experience
btw do you know if I can call an endpoint to make a form without using
export const runtime = 'edge';
?i prefer more control
I don't think so
the edge runtime is needed for Cloudflare Pages
it's in the docs somewhere, check it out
like I have to use it for dynamic routes
when i read the
request
which in theory is the same for formsthat's a shame, because i have only ~15 pages and i am already at the limit of max. of 10mb
dang what? 10mb for 15 pages sounds crazy
what kind of website is it?
and every time i declare
export const runtime = 'edge';
, then it takes ~0.8mb. So, I am looking for ways to not use export const runtime = 'edge';
it's a CRUD app with auth, that's it reallyAlso, just saw the blog post in your bio. Absolutely based, ill read it later
hmmmm
what's stopping you from making a dedicated route handler and controlling the form with a client component to send to the route handler?
I can do that too,
Q1. Do I have to declare
export const runtime = 'edge'
in every route.ts
?
Q2. Do I have to declare export const runtime = 'edge'
in page.tsx
when making a request to the endpoint?I'm doing i18n on my layout so it's on the edge runtime, and it only takes up 270kb
are you using nextjs and next-on-pages?
1. yeah, here are the relevant docs https://developers.cloudflare.com/pages/framework-guides/nextjs/deploy-a-nextjs-site/#edge-runtime
2. Depends how you're making the request. The only time I used the edge runtime for any of my pages is when they're dynamic and need to access the request
Cloudflare Docs
Full-stack deployment · Cloudflare Pages docs
Deploy a full-stack Next.js site (recommended).
like for i18n routing
yup!
the edge runtime thing is the limitation im facing
with i18n
because i can't statically generate the pages due to being forced to use the edge runtime on the layout
so request usage go up
also how the router counts each
<Link>
navigation as a request
so I had to optimize my code to use Client components to lessen the reliance on the request-based routing
but other than that, no issuesyeah, that makes sense
but I also don't use Server Actions so take my thoughts with a grain of salt 😜
tbf at this point i might get rid of them
how do you know its 270kb?
my build logs say so
when I deploy
also when you run
npm run build
iircdo you have auth or have forms? e.g., react-hook-form
im on mobile atm, so not sure
My auth is done on the client with Supabase
with RLS
so no need for server interaction
no forms
anyway, let me know if you find a way to optimize your code
im curious to see the issue
god speed!
thanks!
@Firu it was Sentry, it added ~1445kb to each edge function. Now, I don't know what I should use instead of Sentry
OOF, no wonder
glad you figured it out
TIL
thanks!
Did you manage you figure out an alternative, @lettucebaran?
I'm on the same boat at the moment, Cloudflare Pages won't build my site & the bundle sizes ballooned 😂
I tried removing the client config to opt-out of bundling the code with the client, but it doesn't help
Nope. My app doesn't have an error tracker 🥲
I was thinking of adding Sentry only in the FE (assuming that won't drastically increase the bundle size)
Have you tried it?
Also I found this https://axiom.co/
Axiom
Stop sampling, observe every event – Axiom
100% of your data for every possible need: o11y, security, analytics, and new insights.
i'll look into it next
Nope
@lettucebaran it's what we're looking for
not as feature rich or "handholdy" as Sentry
but also not bloated at all
my bundle sizes are back to normal
you get to choose what to log
so not necessarily just for errors
great tech
and their free tier is 0.5TB per month with 30d retention
Nice, thanks for the update
Did you settle on this tool to observe the app?
Yep
Pretty happy with it so far
It's my first time implementing o11y in-depth, so I'm not the right person to judge whether it's perfect
but it fulfills its immediate utility at the moment as an error & logger for us to drill-down & investigate app errors
both server & client