Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
In this tutorial, Iām going to show you how to create a tour diary app using Next, Redux, Ant design and Cosmic JS. It will cover all available options to CRUD using CosmicĀ JS.
TL;DR
Download the GitHub repo.Check out theĀ demo.
Prerequisites
You will be required to install Node JS and npm before starting. Make sure you already have them installed.
Getting Started:
First, we will setup the bucket in CosmicĀ JS.
Setup bucket:To create the bucket, login to Cosmic JS and click add ānewĀ bucketā.
Select start fromĀ scratch.
Import Bucket Data:Download this bucket.json file. And in Settings -> Import / Export Data, click āAdd Import Fileā and choose the downloaded file. It will import all the Object Types and requiredĀ data.
Now we will work on application.
Doing everything using the existing gitĀ repo
You need to have git installed in your system in order to clone the repository. Once done run the following command through terminal or commandĀ line:
git clone https://github.com/cosmicjs/next.js-tour-diarycd next.js-tour-diarynpm installnpm run dev
package.json will look likeĀ this:
What weāre installing andĀ why
- Weāre going to use Next and Redux libraries to create components and managing state inĀ Next.
- Weāre using next-routes package to navigate between ourĀ pages.
- Weāre using antd package to create beautiful layouts using react components. Weāre using babel-plugin-import, babel-plugin-inline-import, babel-plugin-transform-decorators-legacy for integrating ant design withĀ next.
- Weāre going to use cosmicjs library to handle our requests to our Cosmic JSĀ bucket.
- react-draft-wysiwyg is used for editor & draft-js, immutable, html-to-draftjs, draftjs-to-html, react-html-parser has been installed to interact with its content andĀ state.
- Weāre using react-medium-image-zoom for image zoomingĀ effect.
- Weāre using moment for time and date manipulation.
- Weāre using cross-env for setting environment variables and babel-plugin-inline-dotenv for setting them by creatingĀ .env file in ourĀ project.
- Weāre using eslint and a predefined set of rules in eslint-config-rallycoding for codeĀ linting.
- Weāre using react-cookies for managing our redux store since it got destroyed in pageĀ reload.
Building ourĀ app
Once weāre done installing every required package by running npm install, letās start creating ourĀ app.
Letās create our TourDetailModal component by creating a file in Tour/TourDetailModal.jsand adding the following code inĀ it:
TourDetailModal.js
This is the abbreviated version of the article that originally appeared on CosmicĀ JS.
ConclusionSo, this is an app where every scenario of Cosmic RESTful API using the Cosmic JS npm package is covered (CRUD). I hope you like the tutorial. If you have any questions please reach out to Cosmic JS on Twitter and join the Cosmic JS Community onĀ Slack.
How to build a Tour Diary App using Next.js and Cosmic JS was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.