timothymiller / t4-app

A powerful cross-platform UI toolkit for building actually native iOS, Android, macOS, Windows, Linux, and Progressive Web Apps with React (Native).
https://t4stack.com
MIT License
1.45k stars 77 forks source link

[feature-request] Add tauri support for native desktop #15

Closed agustif closed 1 year ago

agustif commented 1 year ago

Hey, loving the project, I actually found it in the t3/cua createuniversalapp discord about t4, and that's where they recently landed tauri.

Wondering if it would be nice to bring tauri also inside the nextjs app into the t4 stack?

albbus-stack commented 1 year ago

Yeah I could do this easily, I'm the one who implemented it over at CUA. We have to see if it's compatible with our current next app.

agustif commented 1 year ago

Yeah I could do this easily, I'm the one who implemented it over at CUA. We have to see if it's compatible with our current next app.

Awesome, I was just actually checking your create-t3-app repo so it was funny that you commented so fast, thanks and appreciate it. hope it's an easy integration!

No hurries in my part, but it's certainly desirable to be able to run the same codebase in all the platforms!

Love all the t* stacks

albbus-stack commented 1 year ago

I guess that middleware support is not available, let me try...

https://nextjs.org/docs/app/building-your-application/deploying/static-exports#unsupported-features

albbus-stack commented 1 year ago

I guess that middleware support is not available, let me try...

https://nextjs.org/docs/app/building-your-application/deploying/static-exports#unsupported-features

Failing with:

../../node_modules/scheduler/cjs/scheduler.production.min.js
A Node.js API is used (MessageChannel at line: 121) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
../../node_modules/scheduler/cjs/scheduler.production.min.js
../../node_modules/scheduler/index.js
../../node_modules/react-dom/cjs/react-dom.production.min.js
../../node_modules/react-dom/index.js
../../node_modules/next/dist/esm/client/script.js
../../node_modules/next/dist/esm/shared/lib/router/router.js
albbus-stack commented 1 year ago

We'll have to see with @timothymiller how can we bundle a PWA to make up for this.

timothymiller commented 1 year ago

The reason why I did not initially include Tauri support in T4 was because browser support for installing a PWA to the homescreen is universal across all the platforms right now. Even Safari supports it now.

I do see some value in supporting native desktop, but I see some hurdles blocking 100% code sharing with web.

  1. Back/Forward navigation would need to be handled by a global component and/or button listeners.
  2. No server side rendering support. Would need to build in client side fetching for these use cases.
  3. We would need client side useEffect checks for auth status, instead of middleware. This is similar to how Expo does it currently.

It's entirely possible React Native for desktop is a better solution in the medium to long term.

However, I do have some ideas on potential solutions in the meantime.

Create a separate project folder inside apps for tauri native desktop. It could import the pages from Next.js, except for server side rendered routes. All the Tauri specific code could live in this new tauri folder.

bram209 commented 1 year ago

Nextjs support static exports

See:

https://tauri.app/v1/guides/getting-started/setup/next-js/#nextjs-static-exports

And:

https://nextjs.org/docs/app/building-your-application/deploying/static-exports#supported-features

So I think you can use server components too?

albbus-stack commented 1 year ago

Tauri is now being implemented over on the tauri branch as per #26 after I resolve the conflicts.

timothymiller commented 1 year ago

Tauri support is now in the tauri branch

It's really nice since it adds back/forward buttons to the window title. Still need some work on the client side portions, however.