Santi
Santi

Reputation: 529

Deploy react-router-v7 to Vercel

I upgraded my remix app to react-router-v7 but cannot get it to deploy on Vercel (used to work fine).

I have done all the things all the internet says but something is going wrong with the type imports it seems.

This is the errorlog

✓ 114 modules transformed.
x Build failed in 1.54s
Could not resolve "./+types/layout" from "app/routes/website/layout.tsx"
file: /vercel/path0/app/routes/website/layout.tsx
    at getRollupError (file:///vercel/path0/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
    at error (file:///vercel/path0/node_modules/rollup/dist/es/shared/parseAst.js:392:42)
    at ModuleLoader.handleInvalidResolvedId (file:///vercel/path0/node_modules/rollup/dist/es/shared/node-entry.js:20088:24)
    at file:///vercel/path0/node_modules/rollup/dist/es/shared/node-entry.js:20048:26 {
  code: 'UNRESOLVED_IMPORT',
  exporter: './+types/layout',
  id: '/vercel/path0/app/routes/website/layout.tsx',
  watchFiles: [
    '/vercel/path0/node_modules/@react-router/dev/dist/config/defaults/entry.client.tsx',
    '/vercel/path0/app/root.tsx',
    '/vercel/path0/app/routes/website/layout.tsx',
    '/vercel/path0/app/routes/website/index.tsx',
    '/vercel/path0/app/routes/website/login.tsx',
    '/vercel/path0/app/routes/website/forgot-password.tsx',
    '/vercel/path0/app/routes/website/signup.tsx',
    '/vercel/path0/app/routes/website/signup.success.tsx',
    '/vercel/path0/app/routes/website/privacy.tsx',
    '/vercel/path0/app/routes/website/terms.tsx',
    '/vercel/path0/app/routes/website/update-password.tsx',
    '/vercel/path0/app/routes/website/logout.tsx',

It goes on much longer basically every file there is gives this error. Locally it works fine.

Anyone any idea I am quite desperate.

Upvotes: 0

Views: 583

Answers (2)

leerob
leerob

Reputation: 3157

React Router v7 is now supported on Vercel: https://x.com/vercel_changes/status/1890104465862332725

Upvotes: 2

andersr
andersr

Reputation: 1051

Have you tried using the vercel template at https://github.com/remix-run/react-router-templates?

You can just copy the configs from https://github.com/remix-run/react-router-templates/tree/main/vercel Specifically, you'll want to update:

  • your build script to "build": "react-router build && node vercel/prepare.js",
  • copy dev-server.js and add to root.
  • copy the server dir.
  • copy the vercel dir.
  • update vite.config.ts to match
  • remove any existing start script

Hope that helps.

Upvotes: 0

Related Questions