Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@astrojs/vercel

Package Overview
Dependencies
Maintainers
4
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astrojs/vercel - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

6

CHANGELOG.md
# @astrojs/vercel
## 0.2.4
### Patch Changes
- [#3677](https://github.com/withastro/astro/pull/3677) [`8045c8ad`](https://github.com/withastro/astro/commit/8045c8ade16fe4306448b7f98a4560ef0557d378) Thanks [@Jutanium](https://github.com/Jutanium)! - Update READMEs
## 0.2.3

@@ -4,0 +10,0 @@

2

dist/edge/adapter.js

@@ -1,2 +0,2 @@

import { writeJson, getVercelOutput } from "../lib/fs.js";
import { getVercelOutput, writeJson } from "../lib/fs.js";
import { getRedirects } from "../lib/redirects.js";

@@ -3,0 +3,0 @@ const PACKAGE_NAME = "@astrojs/vercel/edge";

/// <reference types="node" />
import type { PathLike } from 'node:fs';
export declare function writeJson<T extends any>(path: PathLike, data: T): Promise<void>;
export declare function writeJson<T>(path: PathLike, data: T): Promise<void>;
export declare function emptyDir(dir: PathLike): Promise<void>;
export declare const getVercelOutput: (root: URL) => URL;

@@ -0,4 +1,4 @@

import { nodeFileTrace } from "@vercel/nft";
import * as fs from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { nodeFileTrace } from "@vercel/nft";
async function copyDependenciesToFunction(root, functionFolder, serverEntry) {

@@ -5,0 +5,0 @@ const entryPath = fileURLToPath(new URL(`./${serverEntry}`, functionFolder));

@@ -1,2 +0,2 @@

import { writeJson, getVercelOutput } from "../lib/fs.js";
import { getVercelOutput, writeJson } from "../lib/fs.js";
import { copyDependenciesToFunction } from "../lib/nft.js";

@@ -3,0 +3,0 @@ import { getRedirects } from "../lib/redirects.js";

@@ -0,3 +1,3 @@

import { polyfill } from "@astrojs/webapi";
import { App } from "astro/app";
import { polyfill } from "@astrojs/webapi";
import { getRequest, setResponse } from "./request-transform.js";

@@ -4,0 +4,0 @@ polyfill(globalThis, {

@@ -1,2 +0,2 @@

import { getVercelOutput, writeJson, emptyDir } from "../lib/fs.js";
import { emptyDir, getVercelOutput, writeJson } from "../lib/fs.js";
import { getRedirects } from "../lib/redirects.js";

@@ -3,0 +3,0 @@ const PACKAGE_NAME = "@astrojs/vercel/static";

{
"name": "@astrojs/vercel",
"description": "Deploy your site to Vercel",
"version": "0.2.3",
"version": "0.2.4",
"type": "module",

@@ -41,4 +41,4 @@ "author": "withastro",

"devDependencies": {
"astro": "1.0.0-beta.33",
"astro-scripts": "0.0.4"
"astro": "1.0.0-beta.60",
"astro-scripts": "0.0.6"
},

@@ -45,0 +45,0 @@ "scripts": {

# @astrojs/vercel
Deploy your server-side rendered (SSR) Astro app to [Vercel](https://www.vercel.com/).
This adapter allows Astro to deploy your SSR site to [Vercel](https://www.vercel.com/).
Use this integration in your Astro configuration file:
- <strong>[Why Astro Vercel](#why-astro-vercel)</strong>
- <strong>[Installation](#installation)</strong>
- <strong>[Usage](#usage)</strong>
- <strong>[Configuration](#configuration)</strong>
- <strong>[Examples](#examples)</strong>
- <strong>[Troubleshooting](#troubleshooting)</strong>
- <strong>[Contributing](#contributing)</strong>
- <strong>[Changelog](#changelog)</strong>
## Why Astro Vercel
If you're using Astro as a static site builder—its behavior out of the box—you don't need an adapter.
If you wish to [use server-side rendering (SSR)](https://docs.astro.build/en/guides/server-side-rendering/), Astro requires an adapter that matches your deployment runtime.
[Vercel](https://www.netlify.com/) is a deployment platform that allows you to host your site by connecting directly to your GitHub repository. This adapter enhances the Astro build process to prepare your project for deployment through Vercel.
## Installation
First, install the `@astrojs/vercel` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
```sh
npm install @astrojs/vercel
```
Then, install this adapter in your `astro.config.*` file using the `adapter` property (note the import from `@astrojs/vercel/serverless` - see [targets](#targets)).
__astro.config.mjs__
```js

@@ -16,6 +42,24 @@ import { defineConfig } from 'astro/config';

When you build your project, Astro will know to use the `.vercel/output` folder format that Vercel expects.
### Targets
## Deploying
You can deploy to different targes:
- `edge`: SSR inside an [Edge function](https://vercel.com/docs/concepts/functions/edge-functions).
- `serverless`: SSR inside a [Node.js function](https://vercel.com/docs/concepts/functions/serverless-functions).
- `static`: generates a static website following Vercel's output formats, redirects, etc.
> **Note**: deploying to the Edge has [its limitations](https://vercel.com/docs/concepts/functions/edge-functions#known-limitations). An edge function can't be more than 1 MB in size and they don't support native Node.js APIs, among others.
You can change where to target by changing the import:
```js
import vercel from '@astrojs/vercel/edge';
import vercel from '@astrojs/vercel/serverless';
import vercel from '@astrojs/vercel/static';
```
## Usage
📚 **[Read the full deployment guide here.](https://docs.astro.build/en/guides/deploy/vercel)**
You can deploy by CLI (`vercel deploy`) or by connecting your new repo in the [Vercel Dashboard](https://vercel.com/). Alternatively, you can create a production build locally:

@@ -28,4 +72,2 @@

## Requirements
**Vercel's [Build Output API](https://vercel.com/docs/build-output-api/v3) must be enabled.** You must enable it yourself by setting the environment variable: `ENABLE_VC_BUILD=1`.

@@ -46,22 +88,18 @@

## Targets
## Configuration
You can deploy to different targes:
This adapter does not expose any configuration options.
- `edge`: SSR inside a [Edge function](https://vercel.com/docs/concepts/functions/edge-functions).
- `serverless`: SSR inside a [Node.js function](https://vercel.com/docs/concepts/functions/serverless-functions).
- `static`: generates a static website following Vercel's output formats, redirects, etc.
## Examples
> **Note**: deploying to the Edge has [its limitations](https://vercel.com/docs/concepts/functions/edge-functions#known-limitations) — they can't be more than 1 MB in size and they don't support native Node.js APIs, among others.
## Troubleshooting
You can change where to target by changing the import:
**A few known complex packages (example: [puppeteer](https://github.com/puppeteer/puppeteer)) do not support bundling and therefore will not work properly with this adapter.** By default, Vercel doesn't include npm installed files & packages from your project's `./node_modules` folder. To address this, the `@astrojs/vercel` adapter automatically bundles your final build output using `esbuild`.
```js
import vercel from '@astrojs/vercel/edge';
import vercel from '@astrojs/vercel/serverless';
import vercel from '@astrojs/vercel/static';
```
## Contributing
## Limitations
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR!
**A few known complex packages (example: [puppeteer](https://github.com/puppeteer/puppeteer)) do not support bundling and therefore will not work properly with this adapter.** By default, Vercel doesn't include npm installed files & packages from your project's `./node_modules` folder. To address this, the `@astrojs/vercel` adapter automatically bundles your final build output using `esbuild`.
## Changelog
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/
import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
import { writeJson, getVercelOutput } from '../lib/fs.js';
import { getVercelOutput, writeJson } from '../lib/fs.js';
import { getRedirects } from '../lib/redirects.js';

@@ -5,0 +5,0 @@

@@ -0,3 +1,7 @@

// NOTE(fks): Side-effect -- shim.js must run first. This isn't guaranteed by
// the language, but it is a Node.js behavior that we rely on here. Keep this
// separate from the other imports so that it doesn't get organized & reordered.
import './shim.js';
// Normal Imports
import type { SSRManifest } from 'astro';

@@ -4,0 +8,0 @@ import { App } from 'astro/app';

import type { PathLike } from 'node:fs';
import * as fs from 'node:fs/promises';
export async function writeJson<T extends any>(path: PathLike, data: T) {
export async function writeJson<T>(path: PathLike, data: T) {
await fs.writeFile(path, JSON.stringify(data), { encoding: 'utf-8' });

@@ -6,0 +6,0 @@ }

@@ -0,4 +1,4 @@

import { nodeFileTrace } from '@vercel/nft';
import * as fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { nodeFileTrace } from '@vercel/nft';

@@ -5,0 +5,0 @@ export async function copyDependenciesToFunction(

@@ -1,2 +0,2 @@

import type { AstroConfig, RoutePart, RouteData } from 'astro';
import type { AstroConfig, RouteData, RoutePart } from 'astro';

@@ -3,0 +3,0 @@ // https://vercel.com/docs/project-configuration#legacy/routes

import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
import { writeJson, getVercelOutput } from '../lib/fs.js';
import { getVercelOutput, writeJson } from '../lib/fs.js';
import { copyDependenciesToFunction } from '../lib/nft.js';

@@ -5,0 +5,0 @@ import { getRedirects } from '../lib/redirects.js';

@@ -0,4 +1,4 @@

import { polyfill } from '@astrojs/webapi';
import type { SSRManifest } from 'astro';
import { App } from 'astro/app';
import { polyfill } from '@astrojs/webapi';
import type { IncomingMessage, ServerResponse } from 'node:http';

@@ -5,0 +5,0 @@

@@ -0,3 +1,3 @@

import type { IncomingMessage, ServerResponse } from 'node:http';
import { Readable } from 'node:stream';
import type { IncomingMessage, ServerResponse } from 'node:http';

@@ -4,0 +4,0 @@ /*

import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
import { getVercelOutput, writeJson, emptyDir } from '../lib/fs.js';
import { emptyDir, getVercelOutput, writeJson } from '../lib/fs.js';
import { getRedirects } from '../lib/redirects.js';

@@ -5,0 +5,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc