# How to Self Host Trigger.dev V2 the Right Way

If you're looking to use [https://trigger.dev/](https://trigger.dev/), and want to use V2 you're going to want to self host since they aren't offering new customers to the V2 cloud platform.

First create an account at [https://www.doppler.com/](https://www.doppler.com/) and create a new project called trigger-v2.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717603198884/96b61d26-6d2b-47eb-8f36-c5118dc06281.png align="center")

Then follow the guide on the trigger docs for how to deploy to render.com with a few adjustments.

[https://trigger.dev/docs/documentation/guides/self-hosting/render](https://trigger.dev/docs/documentation/guides/self-hosting/render)

1. Go to [https://www.uuidgenerator.net/](https://www.uuidgenerator.net/) and get two UUIDs. In the name field paste the UUId twice. We do this because the deployed render.com instance is publicly assessible to anyone on the web. So we are going to use *security by obsucation* to fudge the URL as much as possible to prevent people from landing our page.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717604094669/0ff54c2c-3262-4076-b3ac-952cd453200d.png align="center")
    
2. Instead of pasting the environment variables manually in render.com, add them to your doppler project and then use the integrations feature to synchronize it with your project.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717603452786/bcccad74-9e01-433e-8671-56e6dcdf6337.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717603465622/8ccd3e4c-3874-4a4b-b240-e23067f90a77.png align="center")
    
3. Go to [https://neon.tech/](https://neon.tech/) to get a serverless postgres database. Use this as the database environment variable.
    
4. Create a github app and link it to your project.
    

Once its deployed, you can just go the deployed URL and login in with your github.

## Extras: Next.js Integration

For next.js, you will probably want to integrate [status hooks](https://trigger.dev/docs/documentation/guides/react-hooks-statuses) in your project. However the default settings won't work anymore because we are now self hosting.

Logically we will want to change the API url parameter in our `TriggerProvider`. However if we just use the same `render.com` url as our deployed instance, we are going to immediately lose our *security by obfuscation*, since anybody who lands on our web page can open the next console and see that URL.

Instead what we need is some kind of reverse proxy. We can leverage [Next.js rewrites](https://nextjs.org/docs/pages/api-reference/next-config-js/rewrites) to do this.

First change your `apiUrl` to `/trigger-v2`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717603842918/bb6bfe41-cf1a-4b64-8b15-ef9d94462d07.png align="center")

Then in your `next.config.js`, add a rewrites parameter with `source: /trigger-v2/:api*` and `destination: ${env.TRIGGER_API_URL}/:api*` respectively.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717603931437/048a6a0c-6d65-4e48-bc92-4546e06f8778.png align="center")

Now your trigger react hooks will get reverse proxied to your deployed render.com instance.

If you liked this article feel free to drop me a DM or email!
