To set up remix project, please follow along the following link that will guide to learn everything that's in it.
Obtain the QStash secret key
Once you have created an Upstash account and are logged in, go to the QStash tab.
Now, scroll down till you see the Environment Keys section, and click the copy button and save it somewhere safe to be used further in your application.
Once you have setup the Remix project, create an .env file if it doesn’t exists. You are going to add the secret keys obtained in the sections above.
The .env file should contain the following keys:
With that done, the configuration set up is complete on your end. You can now see the application in action by executing the following command in your terminal and visiting localhost:3000.
Follow along to understand the relevant parts of the code that allow you to successfully build your own Instagram post engine.
Create a Cloudflare Workers Endpoint
We will create a Cloudflare Workers endpoint with the following command.
Once setup is complete copy the following code in your index.(js|ts) file
Create a callback Endpoint
A callback endpoint is necessary because once we initiate the QStash with a scheduler, the destination endpoint (in our case, a Cloudflare Workers) will call our callback endpoint and provide the necessary information.
Create a QStash with a scheduler
We instantiate the QStash on CTA (in our case, when the user clicks the publish button).
That was a lot of learning! You’re all done now ✨
Deploy to Fly.io
The Remix template comes in with a baked-in setup for Fly.io, specifically pertaining to:
Dockerfile
fly.toml
.dockerignore
Once you have a Fly.io account, you can create an app in Fly.io by executing the following command in your terminal at the root directory:
and deploy to Fly.io executing the following command in your terminal:
Conclusion
In this guide, you learned how to publish an Instagram post using QStash. With QStash, you gain the ability to alleviate the load on your application and execute the job in the background, all with just a few lines of code.