Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from NextJS -> Vite / plain React for demos #83

Merged
merged 27 commits into from
Mar 11, 2024
Merged

Conversation

rkistner
Copy link
Contributor

@rkistner rkistner commented Feb 28, 2024

NextJS's server-side rendering mostly just conflicts with our local-first approach, with multiple workarounds required to make it functional. This attempts to simplify the supabase-todolist demo by not using NextJS.

The app is mostly unchanged. The main changes are:

  1. Use Vite as a bundler.
  2. Use react-router instead of NextJS navigation.
  3. Shuffle the providers around a bit to better work with react-router.
  4. Move lists out as a separate TodoListsWidget.

In the future, it will also allow:

  1. Using react-router's loaders to load data before navigating to a new page - see POC: Preloading queries #84

This similarly migrates the Yjs demo, adds a new "example-nextjs" to still have the basic boilerplate for NextJS available.

This also fixes some null-check issues, giving better feedback when credentials are not provided.

TODO:

  • Check if more config or dependencies can be cleaned up.
  • Rename demo to react-supabase-todolist.
  • Do the same for the Yjs demo.
  • Add a new basic NextJS demo, to still have a working example (similar to the current Vite demo).
  • Fully offline-capable PWA.

@rkistner rkistner changed the title Switch from NextJS -> Vite for supabase-todolist demo Switch from NextJS -> Vite for demos Mar 5, 2024
@rkistner rkistner marked this pull request as ready for review March 5, 2024 14:16
@@ -0,0 +1 @@
NEXT_PUBLIC_POWERSYNC_URL=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to mention setting this field (and renaming this file) in the Readme?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually getting sync to work would also require setting up a connector. The other two examples (example-vite and example-webpack) also don't have anything for that.

Do you think it's worth expanding all those examples, perhaps with instructions using temporary development tokens?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As newcomer, fake auth connection is good for learning and testing purposes.

@benitav
Copy link
Contributor

benitav commented Mar 6, 2024 via email

stevensJourney
stevensJourney previously approved these changes Mar 6, 2024
@rkistner
Copy link
Contributor Author

rkistner commented Mar 7, 2024

IIRC we published those to showcase bundling with these frameworks; I think showcasing the sync setup is also going to be helpful, but could also be a future addition. If we implement this later I'd just say we add a note here explaining how this field would be used, or remove it.

@benitav I added minimal notes on configuring the example with a development token.

stevensJourney
stevensJourney previously approved these changes Mar 11, 2024
@rkistner rkistner merged commit be8d8d8 into main Mar 11, 2024
2 checks passed
@rkistner rkistner deleted the todolist-demo-vite branch March 11, 2024 15:39
@rkistner rkistner changed the title Switch from NextJS -> Vite for demos Switch from NextJS -> Vite / plain React for demos Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants