This is an example of how to use WatermelonDB with Next.js. An optional backend for this example can be found here. Some non-obvious things are done in this example that is not explained in the docs:
- We have to implement a custom
DatabaseProvider
. The provider is defined indb-provider.tsx
and used in the rootlayout.tsx
. - We have make use of hooks to access the database, otherwise the observability does not work.
Install the dependencies and start the development server:
npm install
npm run dev
Navigate to http://localhost:3000 to see the example in action.