-
Notifications
You must be signed in to change notification settings - Fork 10k
New guide for migrating from Vercel to Workers #21959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ToriLindsay
merged 7 commits into
cloudflare:production
from
thomas-desmond:tdesmond-vercel-to-workers
Apr 30, 2025
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6de7173
New guide for migrating from Vercel to Workers
thomas-desmond ab73410
Create migrations folder under static-assets and move related content…
thomas-desmond 044c6ff
Update src/content/docs/workers/static-assets/migrations/vercel-to-wo…
thomas-desmond d60eba6
Update src/content/docs/workers/static-assets/migrations/index.mdx
thomas-desmond a828b0b
Fix broken links
thomas-desmond a7d944f
Merge branch 'tdesmond-vercel-to-workers' of https://github.com/thoma…
thomas-desmond 8f0ac45
Merge branch 'production' into tdesmond-vercel-to-workers
thomas-desmond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
src/content/docs/workers/static-assets/migrations/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| pcx_content_type: navigation | ||
| title: Migrations | ||
| sidebar: | ||
| order: 11 | ||
| head: [] | ||
| description: Learn how to migrate your applications to Cloudflare Workers. | ||
| --- | ||
|
|
||
| import { | ||
| Description, | ||
| DirectoryListing, | ||
| } from "~/components"; | ||
|
|
||
| <Description> | ||
| Bring your existing applications to Cloudflare Workers. | ||
| </Description> | ||
|
|
||
| Take advantage of Cloudflare's global network and migrate your existing applications to Workers. | ||
|
|
||
| <DirectoryListing folder="workers/static-assets/migrations" /> | ||
File renamed without changes.
85 changes: 85 additions & 0 deletions
85
src/content/docs/workers/static-assets/migrations/vercel-to-workers.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| --- | ||
| updated: 2025-04-25 | ||
| difficulty: Beginner | ||
| pcx_content_type: tutorial | ||
| title: Migrate from Vercel to Workers | ||
| --- | ||
|
|
||
| import { WranglerConfig } from "~/components"; | ||
|
|
||
| In this tutorial, you will learn how to migrate your Vercel application to Cloudflare Workers. | ||
|
|
||
| You should already have an existing project deployed on Vercel that you would like to host on Cloudflare Workers. Vercel specific features are not supported by Cloudflare Workers. Review the [Workers compatibility matrix](/workers/static-assets/migrate-from-pages/#compatibility-matrix) for more information on what is supported. | ||
|
|
||
| ## Frameworks | ||
|
|
||
| Some frameworks like Next.js, Astro with on demand rendering, and others have specific guides for migrating to Cloudflare Workers; refer to our [framework guides](/workers/frameworks/) for more information. If your framework has a **Deploy an existing project on Workers** guide, follow that guide for specific instructions. Otherwise, continue with the steps below. | ||
thomas-desmond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Find your build command and build directory | ||
|
|
||
| To move your application to Cloudflare Workers, you will need to know your build command and build directory. Cloudflare Workers will use this information to build and deploy your application. We'll cover how to find these values in the Vercel Dashboard below. | ||
|
|
||
| In your Vercel Dashboard, find the project you want to migrate to Workers. Go to the **Settings** tab for your specific project and find the **Build & Development settings** panel. You will find the **Build Command** and **Output Directory** fields there. If you are using a framework, these values may not be filled in but will show the defaults used by the framework. Save these for deploying to Cloudflare Workers. In the below image, the **Build Command** is `npm run build`, and the **Output Directory** is `dist`. | ||
|
|
||
|  | ||
|
|
||
| ## Create a wrangler file | ||
|
|
||
| In the root of your project, create a `wrangler.jsonc` or `wrangler.toml` file (`wrangler.jsonc` is recommended). What goes in the file depends on what type of application you are deploying: static or single-page application. | ||
|
|
||
| For each case, be sure to update the `<your-project-name>` value with the name of your project and `<your-build-directory>` value with the build directory from Vercel. Be sure to set the right pathing, for example `./dist` if the build directory is `dist` or `./build` if your build directory is `build`. | ||
|
|
||
| For a **static site**, you will need to add the following to your wrangler file. | ||
|
|
||
| <WranglerConfig> | ||
|
|
||
| ```jsonc | ||
| { | ||
| "name": "<your-project-name>", | ||
| "compatibility_date": "2025-04-23", | ||
| "assets": { | ||
| "directory": "<your-build-directory>", | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| </WranglerConfig> | ||
|
|
||
| For a **single page application**, you will need to add the following to your wrangler file, which includes the `not_found_handling` field. | ||
|
|
||
| <WranglerConfig> | ||
|
|
||
| ```jsonc | ||
| { | ||
| "name": "<your-project-name>", | ||
| "compatibility_date": "2025-04-23", | ||
| "assets": { | ||
| "directory": "<your-build-directory>", | ||
| "not_found_handling": "single-page-application" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| </WranglerConfig> | ||
|
|
||
| Some frameworks provide specific guides for migrating to Cloudflare Workers. Please refer to our [framework guides](/workers/frameworks/) for more information. If your framework includes a “Deploy an existing project on Workers” guide, follow it for detailed instructions. | ||
|
|
||
| ## Create a new Workers project | ||
|
|
||
| Your application has the proper configuration to be built and deployed to Cloudflare Workers. | ||
|
|
||
| The [Connect a new Worker](/workers/ci-cd/builds/#connect-a-new-worker) guide will instruct you how to connect your GitHub project to Cloudflare Workers. In the configuration step, ensure your build command is the same as the command you found on Vercel. Also, the deploy command should be the default `npx wrangler deploy`. | ||
|
|
||
| ## Add a custom domain | ||
|
|
||
| Workers Custom Domains only supports domains that are configured as zones on your account. A zone refers to a domain (such as example.com) that Cloudflare manages for you, including its DNS and traffic. | ||
|
|
||
| Follow these instructions for [adding a custom domain to your Workers project](/workers/configuration/routing/custom-domains/#add-a-custom-domain). You will also find additional information on creating a zone for your domain. | ||
|
|
||
| ## Delete your Vercel app | ||
|
|
||
| Once your custom domain is set up and sending requests to Cloudflare Workers, you can safely delete your Vercel application. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| For additional migration instructions, review the [Cloudflare Pages to Workers migration guide](/workers/static-assets/migrate-from-pages/). While not Vercel specific, it does cover some additional steps that may be helpful. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.