Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Great improvements, some questions #267

Open
osseonews opened this issue Dec 14, 2024 · 6 comments
Open

Great improvements, some questions #267

osseonews opened this issue Dec 14, 2024 · 6 comments

Comments

@osseonews
Copy link

Hey, thanks for keeping this project alive! Building something like this has always been my dream, but I've been busy with a lot of the other things. Anyway, the move to Astro seems to have been a great move as everything looks and feels better. A few questions:

  1. How are you hosting the Astro app? Using the New Cloudflare Workers frameworks? https://developers.cloudflare.com/workers/frameworks/framework-guides/astro/ . If not, I think this is the way to go. I've tested it with other platforms (I don't know Astro) and this is better than Pages. Cloudflare always has mixed up the 2 and made it confusing, but I think going forward Workers will replace Pages for sure.
  2. In the demo admin dashboard, you have a field for images, but there doesn't seem to be any demo on how to upload an image. Can you supply the code for that? Always have huge difficulties with images. I still think using Cloudflare Images as opposed to R2 is better for images, as Images supplies transformations out of the box. But anyway, some code example would be helpful.
  3. Curious how the experience has been with Astro as compared to something like NextJs?
@tedy5
Copy link

tedy5 commented Dec 16, 2024

I'm not a project dev, but:

  1. Isn't Pages with Edge runtime faster than Workers? No cold start and ability to serve static pages.
    Also, Pages is their newer feature so I doubt Workers will replace it.

  2. About images, the best/cheapest feature would be implementing optimization on the Edge or Workers.
    Other than that, you can always use Cloudflare Images for conversion, while images are hosted in R2 (Still cheaper than hosting directly on their Images product)

  3. I would personally love if it was written in Next.JS as that would make Full-stack app, without need for APIs.

@osseonews
Copy link
Author

  1. This is a total misunderstanding of workers and pages. Pages is Workers. It literally runs on workers. It is just a different implementation because originally running sites on Workers was a bit of pain and had no built in git pipeline. But, that has now changed. Workers Frameworks is the latest platform, and you can read about it here: https://developers.cloudflare.com/workers/frameworks/. This will be the standard going forward after beta. They won't deprecate Pages, but it's doubtful it will be recommended approach on Workers Frameworks is out of beta (early next year). I've tested it extenively and it is much better than pages. No chance i'll ever use pages again.

@osseonews osseonews reopened this Dec 16, 2024
@lane711
Copy link
Owner

lane711 commented Dec 16, 2024

Hey @osseonews , thanks for your questions.

  1. I am hosting demo.sonicjs.com on cloudflare pages using the Astro preset. It works great so far with no issues.
  2. File and image support will be added back soon. I just didn't have the bandwidth to add it into the new version yet. I'd love some help on this. It was working well in the prior version so we do have that as a working code example.
  3. I am a fan of both Astro and Nextjs but I think Astro is more comprehensive and you get more OOTB. Its likely my new goto framework for new sites/projects. Astro with SonicJs on Cloudflare provides a fast, reliable and very inexpensive full stack platform.

@lane711
Copy link
Owner

lane711 commented Dec 16, 2024

@tedy5 Astro + SonicJs is full stack. You can already use the internal API from SonicJs without using HTTP requests if you desire. If you working with a front end framework like React, you likey want a REST API however.

@tedy5
Copy link

tedy5 commented Dec 17, 2024

@osseonews, I doubt that Pages are the same as Workers under the hood.
https://developers.cloudflare.com/workers/static-assets/compatibility-matrix/
It's not the same runtime.
I did a benchmark:
Pages Edge functions first request: 237.35ms
Workers first request: 512.91ms
My suspicion proved to be true - Pages Edge functions are much faster on first request.

@lane711 I'm working with Next.js and can query database/cache directly from Next, but CMS has to be hosted on separate subdomain, while it could be placed at /dashboard if it was written in Next.js :)

@osseonews
Copy link
Author

osseonews commented Dec 17, 2024

You are misunderstanding the build process and routing vs the underlying platform. Anyway, believe what you will, and if you like Pages stick with it. However, I suggest you read the Pages function documentation on Cloudflare's website, where you will learn that: "Pages Functions allows you to build full-stack applications by executing code on the Cloudflare network with Cloudflare Workers. "

I've used Pages for years myself. But, it's just an implementation on top of Workers. Pages only exists because the original way to deploy sites with Workers, called Worker Sites was way too complicated and lacked built in page routing, and a good build pipeline with GitHub integration. However, last year, Cloudflare introduced Workers Static Assets to replace Workers Sites. It brings all the features of Pages to Workers, so you have no need for Pages anymore and Worker Static Assets has more features now (except for routing - but you can use something like Hono for routing, if you want).

Again, if you want to believe Pages is different, that's fine. No harm done. For others, I recommend using the new Workers Static Assets because it's simply better for many reasons (and I know Pages really well). With time Cloudflare will deprecate Pages because it serves no purpose anymore and there is no point dedicating resources to 2 different projects that aim to solve the same issue: how to easily build sites on top of Workers and have access to all the Cloudflare features.

Good luck!

Edit: If you read the Workers Static Assets pages on Cloudflare you will notice that they say: "We plan to bridge the gaps between Workers and Pages and provide ways to migrate your Pages projects to Workers." This is a pretty subtle way of telling you what the future will look like, and it's not Pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants