tauri-docs icon indicating copy to clipboard operation
tauri-docs copied to clipboard

Add guide: Tauri + Nextjs

Open JonasKruckenberg opened this issue 3 years ago • 4 comments

Setup

  • link to nextjs setup
  • link to tauri setup
  • explain how to setup nextjs and tauri in one project
  • configuration
    • configure ecmascript target
    • configure conditional compilation env vars
    • strict port?

Development

  • mention HMR
  • best practices when mapping routes to app views?
  • any other best practices when targeting desktop apps?

Building

  • mention vite build (short)
  • explain how tauri build will find the assets

SSG

  • explain challenges (no window object, no tauri apis)
  • link to @tauri-apps/api/mocks
  • link to vite SSR guide
  • show example config

Plugin recommendations

Does nextjs have plugins? If so what are some good plugins to have? (See vite and rollup guides for examples)

JonasKruckenberg avatar Feb 16 '22 20:02 JonasKruckenberg

I've set up a barebones template repo for using next.js with tauri here https://github.com/kvnxiao/tauri-nextjs-template Modified the development / build commands a bit, and keeping in mind that this is meant to use next.js solely as a frontend project scaffolding tool (similar to create-react-app), and not for its additional server-side rendering features. Meaning that it's only meant for SSG consumption and that next/image optimization is disabled.

screenshot of output build using pre-rendering/SSG (via next build && next export): image

kvnxiao avatar Jul 14 '22 02:07 kvnxiao

I'm wondering if this can somehow be adapted and integrated directly into the yarn create tauri-app command sometime in the future?

kvnxiao avatar Jul 14 '22 02:07 kvnxiao

I'm wondering if this can somehow be adapted and integrated directly into the yarn create tauri-app command sometime in the future?

We're working on a re-write in Rust for create-tauri-app that will allow us to create/add a lot more templates, so this is on the roadmap. Can find more details here: https://github.com/tauri-apps/create-tauri-app/issues/77

lorenzolewis avatar Jul 16 '22 15:07 lorenzolewis

For the time being you could add it to https://github.com/tauri-apps/awesome-tauri tho.

FabianLars avatar Jul 16 '22 18:07 FabianLars

Hey @JonasKruckenberg I made a getting started in this PR I can also translate it in french if you need i just don't know how, im not familiar with docusaurus!

You can ping me up on the discord channel @leone

leon3s avatar Aug 26 '22 15:08 leon3s