{"_id":"@brendonovich/vite-plugin-vercel-ssr","name":"@brendonovich/vite-plugin-vercel-ssr","dist-tags":{"main":"0.0.0-0","latest":"0.0.0-0"},"versions":{"0.0.0-0":{"name":"@brendonovich/vite-plugin-vercel-ssr","version":"0.0.0-0","type":"module","description":"Use vite-plugin-ssr with @brendonovich/vite-plugin-vercel","author":{"name":"Joël Charles","email":"joel.charles91@gmail.com"},"repository":{"type":"git","url":"https://github.com/magne4000/@brendonovich/vite-plugin-vercel"},"main":"./dist/vite-plugin-ssr.cjs","module":"./dist/vite-plugin-ssr.js","exports":{".":{"types":"./dist/vite-plugin-ssr.d.ts","import":"./dist/vite-plugin-ssr.js","require":"./dist/vite-plugin-ssr.cjs"},"./helpers":{"types":"./dist/templates/helpers.d.ts","import":"./dist/templates/helpers.js","require":"./dist/templates/helpers.cjs"}},"types":"./dist/vite-plugin-ssr.d.ts","scripts":{"build":"tsup","dev":"tsup --watch","prepack":"rm -rf dist && pnpm build","typecheck":"tsc -p tsconfig.json --noEmit","lint:ts":"eslint . --max-warnings 0 --ignore-pattern dist"},"devDependencies":{"@brillout/libassert":"^0.5.8","@types/node":"^16.18.21","@vercel/node":"^2.10.0","nanoid":"^4.0.2","tsup":"^6.7.0","typescript":"^5.0.2","vite":"^4.2.1","vite-plugin-ssr":"^0.4.103","@brendonovich/vite-plugin-vercel":"workspace:*"},"license":"MIT","gitHead":"d70fba9a8321660a26b0331d7644c204071d988f","_id":"@brendonovich/vite-plugin-vercel-ssr@0.0.0-0","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-yvsVcsxnlzDu+rkR1XhDsi0KYnSv0VQaTVpj97WftUr4gcSkLZtGYAvQXmbV8BO5SX04qUmOsvgnUoaYj4Qh1A==","shasum":"6372d9cb0ae3abdc4544ee73e7c632154b89263c","tarball":"https://registry.npmjs.org/@brendonovich/vite-plugin-vercel-ssr/-/vite-plugin-vercel-ssr-0.0.0-0.tgz","fileCount":13,"unpackedSize":47177,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDkIGh7r77VLB+Gciwl3gOw24aaLik5nenwlBDv8crSFwIgJFSB+YEZMbnZfJD8w2kHetj3rg88UfUgAgOgWqdbwrQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkP4c3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrSQQ/+OdQK9eM6BsPLbCwwNefsF5Z3Fx5k615hk6EClnHUOFJ6NsLr\r\nTwb8UvPAFgJza8aPtnzW+MW43fYsw6oLYwlWO4NiSP0FBOnQhKGZT5K+1iLQ\r\naZJtHKh8Y4ohP4L1FqFeFoe+cCcbyGXCqKz15ZA58kngT6OoXA7zeliJg6vD\r\nGEF42zPqq5vOSFSTMooL3aYNKXdtsIrbS/YfanBo+jDEeo1y1fXp+Rjhb50Z\r\nH9jRN0ekK4AFx0DEb//kYSTUwgy57VY04IDKW7beFO6DzNxLDamtyubZBUVJ\r\nX01sacHhgO54tjMxtuVFyl2M+Vhs1FI5mfYY1zWSBdqaNISlD4CMwtCqaTNd\r\naRJDm2oTgpYPso6euN1JFYHqRiUTPZGUuYz0g/fN2DGqyVZNzxMjbTFZwgDV\r\ngLmFKEJfT1QYLwdVCPkR6xEcR5J3hAxTUgrP85X1zUfERNks0jbQGwE0eQVA\r\nmj1eS09GGiEDraVrv97Nn07gPA/Os2JjBKx5leH/LLxCvcQB3iPDDvUymt7d\r\n4AH0XTuLEG05v3QcGQAf/hMNpQXJFRZPOZKdBTsfV4zt2PmlrUTQtNNKuEqu\r\nlXq44GDw8mK+nRTSReTB/ooIJFghPqfmhUZkZ7XOb0QyE1JPXieCZfb3Tryi\r\ncQ0e1RbYwWai6cePKkvWML+RY5PrdFbv9Qs=\r\n=ujbY\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"brendonovich","email":"brendonovich@outlook.com"},"directories":{},"maintainers":[{"name":"brendonovich","email":"brendonovich@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vite-plugin-vercel-ssr_0.0.0-0_1681884983515_0.9642741121316596"},"_hasShrinkwrap":false}},"time":{"created":"2023-04-19T06:16:23.400Z","0.0.0-0":"2023-04-19T06:16:23.723Z","modified":"2023-04-19T06:16:23.940Z"},"maintainers":[{"name":"brendonovich","email":"brendonovich@outlook.com"}],"description":"Use vite-plugin-ssr with @brendonovich/vite-plugin-vercel","repository":{"type":"git","url":"https://github.com/magne4000/@brendonovich/vite-plugin-vercel"},"author":{"name":"Joël Charles","email":"joel.charles91@gmail.com"},"license":"MIT","readme":"# @magne4000/vite-plugin-vercel-ssr\n\n[`vite-plugin-ssr`](https://github.com/brillout/vite-plugin-ssr) integration for `vite-plugin-vercel`.\n\n- Versions `0.1.x` are compatible with vite-plugin-ssr@0.4.x\n- Versions `0.0.x` are compatible with vite-plugin-ssr@0.3.x\n\n## Features\n\n- [Support for ISR/Prerender Functions](#isrprerender-functions)\n- [Route strings](https://vite-plugin-ssr.com/route-string) and [filesystem routing](https://vite-plugin-ssr.com/filesystem-routing) are compiled to [routes rules](https://vercel.com/docs/build-output-api/v3#build-output-configuration/supported-properties/routes)\n- A Serverless Function is created by default to handle SSR route. No need to [manually create it](https://github.com/brillout/vite-plugin-ssr_vercel/blob/main/api/ssr.js)\n  - If you need to customize the Function, [some helpers are available](#custom-serverless-function-for-vite-plugin-ssr)\n\n## Usage\n\nInstall this package as a dev dependency and add it to your Vite config like this:\n\n```ts\n// vite.config.ts\nimport { defineConfig } from 'vite';\nimport ssr from 'vite-plugin-ssr/plugin';\nimport vercel from 'vite-plugin-vercel';\nimport vercelSsr from '@magne4000/vite-plugin-vercel-ssr';\n\nexport default defineConfig(async ({ command, mode }) => {\n  return {\n    // `vercelSsr` MUST be after `ssr` and `vercel`\n    plugins: [ssr(), vercel(), vercelSsr()],\n  };\n});\n```\n\n### ISR/Prerender Functions\n\nOfficial documentation: https://vercel.com/docs/build-output-api/v3#vercel-primitives/prerender-functions\n\nTake any of your `.page` file (not `.page.server`) and add the following export:\n\n```ts\n// Now this page is a Prerender Function, meaning that it will be cached on Edge network for 15 seconds.\n// Check official documentation for further details on how it works.\nexport const isr = { expiration: 15 };\n```\n\n:warning: Pages with [route function](https://vite-plugin-ssr.com/route-function) are not compatible with ISR. A warning will be shown if this occurs.\n\n### Custom Serverless Function for vite-plugin-ssr\n\nBy default, a Serverless Function is created to handle all SSR routes.\nIf for any reason you need to customize it, some tools are available:\n\n```ts\nimport type { VercelRequest, VercelResponse } from '@vercel/node';\nimport { renderPage } from 'vite-plugin-ssr/server';\nimport {\n  getDefaultEmptyResponseHandler,\n  // higly recommended to use at least this one, as it handles some internals\n  // that overrides `request.url`\n  getDefaultPageContextInit,\n  getDefaultResponseHandler,\n} from '@magne4000/vite-plugin-vercel-ssr/helpers';\n\nexport default async function handler(\n  request: VercelRequest,\n  response: VercelResponse,\n) {\n  // pageContextInit.url is not necessarily equal to request.url.\n  // It is required for `renderPage` to work properly.\n  const pageContextInit = getDefaultPageContextInit(request);\n  const pageContext = await renderPage(pageContextInit);\n  const { httpResponse } = pageContext;\n\n  if (!httpResponse) {\n    return getDefaultEmptyResponseHandler(response);\n  }\n\n  return getDefaultResponseHandler(response, httpResponse);\n}\n```\n","readmeFilename":"README.md"}