I a building an application that is to function as a webapp and also as a telegram Miniapp. Telegram miniapp has certain special functionalities or features like the initData ,ie the window.Telegram.WebApp.initData
and all available within it. To access these the webapp should be hosted a telegram miniapp, which requires the webapp to be live.
This is not convenient for development and testing purposes.
Is there a way in which i can maybe give my localhost link as the telegram miniapp and run that.
Or what’s the best way for testing and development of Telegram miniapps.
2
Answers
This can be done using Ngrok
Reference Video : https://www.youtube.com/live/HewVC6tUC1w?feature=shared&t=466
Steps :
Goto ngrok.com and signup.
Install and configure ngrok using the steps provided at ngrok dashboard after signup.
Install ngrok npm package in your project.
Add this to your package.json under scripts
"ngrok":"ngrok http http://localhost:port-number"
NOTE : Use the port number your application is running on localhost of your system. If your application runs on
localhost:3000
use port 3000npm run dev
ornpm run start
or whatever.npm run ngrok
Ngrok is fine for testing purposes. However, it has a downside.
You need to click on the ngrok url to properly run the miniapp.
To avoid this, you can use localtunnel instead of Ngrok.
The installation and operation methods are similar.