thgh / vercel-sapper

Vercel builder for Sapper with SSR enabled
MIT License
189 stars 25 forks source link

Vercel Functions #55

Closed richarddavenport closed 3 years ago

richarddavenport commented 3 years ago

Love the package! Made deployment so easy.

I'm trying to get a function going in Vercel. Is it possible to just add the api folder, or is there something else I need to do?

thgh commented 3 years ago

The folder doesn't matter in Sapper, any .js file in the routes folder will run on the server. Note that this builder only creates 1 serverless function that handles all routes. Only static files get special CDN treatment.

richarddavenport commented 3 years ago

Probably wasn't clear. I understand how sapper works. I'm wondering if vercel can run my sapper application, but for any routes that are prefixed with /api run a vercel function. So in essence a sapper application and vercel functions. My assumption is that if the route is /api => function, all other routes => sapper.

I was thinking I could just add the api folder and it would work. So maybe I can ask my question differently. Is it possible to use this package and also create vercel functions? Thanks!

thgh commented 3 years ago

I guess that won't work, I'm not sure why, but recently it was not possible to mix builds and functions. Consider asking there: https://github.com/vercel/next.js/discussions

richarddavenport commented 3 years ago

Thanks for your help! Really appreciate it!

xpnewmedia commented 3 years ago

@richarddavenport did you make any progress in this arena?

richarddavenport commented 3 years ago

@xpnewmedia I ended up just writing my functions within sapper, using server routes They do basically the same thing. They run some code on the back end, except instead of having vercel manage the function it's one vercel function and multiple sapper functions.

antony commented 3 years ago

I believe this is a specific restriction of Vercel which they are in the process of / have fixed.

I haven't had time to try their new stuff yet but once I do I'll report back here and let you know if this is possible.