Hilla type generation to react native

Is it possible to just use hilla generation but have front end with React Native?

I want to use the generated types and api calls but with React Native.

You can try, I’m interested in hearing how it works out.

It should be possible. I haven’t tried it yet, but it is on my list. Check the docs. Endpoint Generator | Reference | React | Hilla Docs You can generate the client code using specific Maven goals or Gradle tasks. TypeScript Client | Reference | React | Hilla Docs Afterwards you can use the standalone Connect Client of Hilla in your React Native app. I’m not sure if you can tell the Connect Client to connect to a host other than localhost.

I tried a few things, but unfortunately it looks not very promising. The package @hilla/frontend, that contains the relevant ConnectClient, relies on a couple of Web-only objects like Document or window. Those objects are not available in React Native. Maybe you could use some kind of polyfill, but this won’t fix all the problems. The ConnectClient tries to determine the URL of the Hilla backend using the location information of the current browser window. Currently, there seems to be no way to override this behaviour. You could apply a custom patch to the npm module, but this is a bit dirty.

You should create a ticket in the Hilla repo about that

Should I? I don’t think the ConnectClient is intended to be used with a non-browser frontend. Do you think it would make sense to extend the library to be more flexible or generic? In my perception Vaadin is promoting PWA as mobile frontend and not native apps :sweat_smile:

It’s always a good idea to document your ideas!

PWA is dead anyway :man_shrugging:

I prefer native apps, but there are other options: https://twitter.com/joonaslehtinen/status/1742618141069541634?t=BB7mc4F8J90agqt0P7JDbg&s=19 :wink: