How do you recommend using SolidStart to access data for native mobile apps?
I'm learning about SolidStart and I'm wondering if I'm making a native mobile app (using Swift) as well, do I need to maintain an API routes file (
POST() { }
and GET() { }
that calls a javascript function like getPostsFromDB
?
API Routes doc: https://docs.solidjs.com/solid-start/building-your-application/api-routes7 Replies
If you want to make both a website and an API for native then yes. Otherwise I wouldn't recommend, you won't end up using any of the features SolidStart provides and it will be weaker then API focused alternatives.
Given you are doing a mobile app, I'd recommend you create a web app with solid (not solid start) and a separate API that can be reused both by the web app and the mobile app
You're going to love the developer experience way more
It will be serving both native and web. It would be nice to use the server rendering and other features that solidStart provides. But based on this I might need to write the API routes myself or go the tradtional route with APIs layer for both.
Well, you can have SSR and use an API from that code. The difference is when you SSR your "server" does the API call, and while on the client, the client does.
IMO, if we're talking about a web application (not a public website), SSR is not only unnecessary but it also overcomplicates things that would normally work.
@Rodrigo Ah thank you, it clicked that I can use
Accept
and be able to listen to both clients requests.
Yeah I understand what you're saying, I'm just building a personal monolith something like pocketbase for side projects, and wanted to learn about SSR since I'm an iOS engineer and there's no concept like SSR there AFAIK.Got you. It's cool to go the SSR route to practice, and also cool to define api routes through SolidStart because, again, practice.
I think I was too into "how to make life better and easier", vs the learn mindset
Thank you! And yeah makes sense to choose the right tool for the right job in prd