Giter VIP home page Giter VIP logo

nextjs-drag-cards-multi-user's Introduction

nextjs-drag-cards-multi-user

This is a prototype of a collaborative draggable card experience, works only in Edge chromium and Firefox for now. Created using NextJS, react-beautiful-dnd, MSW, PubNub and Docker.

Getting Started

To run the cloned application, run the development server:

npm i && npm run dev

Open http://localhost:3000 with your browser to see the result.

Architecture and approach

This is a proof of concept built to understand collaboration, draggability and developing mock services using mswjs. For developing this PoC I used, NextJS as my frontend framework, this helped me in reducing my development time, as the frontend tooling was pre-built in its template. Though it did reduce most of my development time, it did not offer the kind of flexibility I needed for integrating mswjs and DnD(Drag and drop). In my initial stages I encountered many issues with respect ot setting up mswjs.

The reason I chose to go with MSWjs, is because, it is a new framework I wanted to test its limits, and that it truly mocks the http requests unlike other popular libraries like axios-mock-adapter and miragejs.

MSWjs does not work in NextJS without its node server running, and to top it all, it does not work in chrome at all. The mockServiceWorker kept hitting an infinite render loop, because of a nextjs support for node serviceWorker in Chrome. It works fine in Edge chromium and Firefox. In firefox I encountered another issue, mswjs supports only fetch api in firefox, it does not support axios. This is an existing issue in mswjs.

The Drag and drop of cards, was a bit complicated as NextJS has a separate DOM structure. For that I had to hook it up with it _document.tsx use that to render the react-beautiful-dnd changes. The event used in hooking up the drag and drop is the onDragEnd, where I am using the source and target index position to swap positions. I wanted to use dragula for the drag and drop, as it provides real and shadow DOM manipulation, react-beautiful-dnd seemed to accomplish what I needed and it seemed straightforward.

For the mult-user collaboration, I have used pubnub, as its an event driven system, it offer publish and subscribe to a particular channel. Initially, I though of using something like socketio, but pubnub seemed straighforward, and I really like modularism added.

Overall this PoC helped me in gaining insight into the nextjs frontend tooling, how dnd works and event driven systems like pubnub.

Learn More

nextjs-drag-cards-multi-user's People

Contributors

dependabot[bot] avatar shujathkhan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.