This is an example of how to use the Tradingview Charting Library with Next.js and OKX API.
Show case example:
├── components
│ ├── TVChartContainer
│ │ ├── index.tsx
│ │ └── index.module.css
├── pages
│ ├── api
│ │ └── okx-api.ts
│ ├── _app.tsx
│ ├── _document.tsx
│ ├── index.module.css
│ └── index.tsx
├── services
│ ├── okx
│ │ ├── datafeed.ts
│ │ └── streaming.ts
│ └── index.ts
├── styles
│ ├── global.css
│ └── index.ts
- Check that you can view https://github.com/tradingview/charting_library/. If you do not have access then you can request access to this repository here.
- Copy the charting library files
- If you are able to run bash scripts then the
copy_charting_library_files.sh
script can be used to copy the current stable version's files. - If you are not able to run bash scripts then do the following:
- Copy
charting_library
folder from https://github.com/tradingview/charting_library/ to/public/static
folders. - Copy
datafeeds
folder from https://github.com/tradingview/charting_library/ to/public/static
.
- Copy
- If you are able to run bash scripts then the
Then, run the development server:
npm install
npm run dev
# or
yarn
yarn dev
# or
pnpm install
pnpm dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.tsx
. The page auto-updates as you edit the file.
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts
.
The pages/api
directory is mapped to /api/*
. Files in this directory are treated as API routes instead of React pages.
This project uses next/fo
6E9E
nt
to automatically optimize and load Inter, a custom Google Font.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.