Skip to content

Commit

Permalink
enabled without configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
lilnasy committed Nov 1, 2023
1 parent fe28750 commit d23967a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 46 deletions.
15 changes: 3 additions & 12 deletions .changeset/tricky-clocks-end.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
---
'@astrojs/vercel': minor
'@astrojs/vercel': major
---

The Vercel adapter now allows you to enable streaming!
The Vercel adapter now streams responses!

Bring better performance to your visitors by showing them content as it is rendered. The browser can also start loading the required stylesheets and scripts much sooner, which ultimately results in faster full page loads.


```diff
export default defineConfig({
output: "server",
adapter: vercel({
+ streaming: true
}),
});
This brings better performance to your visitors by showing them content as it is rendered. The browser can also start loading the required stylesheets and scripts much sooner, which ultimately results in faster full page loads.
22 changes: 0 additions & 22 deletions packages/integrations/vercel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,28 +281,6 @@ export default defineConfig({
});
```

### streaming

**Type:** `boolean`<br>
**Available for:** Serverless

Determines whether or not the serverless function will stream its response to the browser, sending components as they are rendered.

The default value is `false`. Set this value to `true` in your Vercel adapter configuration to enable streaming.

```diff lang="js"
// astro.config.mjs
import { defineConfig } from 'astro/config';
import vercel from '@astrojs/vercel/serverless';

export default defineConfig({
output: "server",
adapter: vercel({
+ streaming: true
}),
});
```

### Function bundling configuration

The Vercel adapter combines all of your routes into a single function by default.
Expand Down
10 changes: 1 addition & 9 deletions packages/integrations/vercel/src/serverless/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ export interface VercelServerlessConfig {

/** The maximum duration (in seconds) that Serverless Functions can run before timing out. See the [Vercel documentation](https://vercel.com/docs/functions/serverless-functions/runtimes#maxduration) for the default and maximum limit for your account plan. */
maxDuration?: number;

/** Whether to allow the serverless function to stream the response to the browser. */
streaming?: boolean;
}

export default function vercelServerless({
Expand All @@ -122,7 +119,6 @@ export default function vercelServerless({
functionPerRoute = false,
edgeMiddleware = false,
maxDuration,
streaming,
}: VercelServerlessConfig = {}): AstroIntegration {
if (maxDuration) {
if (typeof maxDuration !== 'number') {
Expand Down Expand Up @@ -280,7 +276,6 @@ You can set functionPerRoute: false to prevent surpassing the limit.`
includeFiles: filesToInclude,
excludeFiles,
maxDuration,
streaming,
});
routeDefinitions.push({
src: route.pattern.source,
Expand All @@ -297,7 +292,6 @@ You can set functionPerRoute: false to prevent surpassing the limit.`
includeFiles: filesToInclude,
excludeFiles,
maxDuration,
streaming,
});
routeDefinitions.push({ src: '/.*', dest: 'render' });
}
Expand Down Expand Up @@ -348,7 +342,6 @@ interface CreateFunctionFolderArgs {
includeFiles: URL[];
excludeFiles?: string[];
maxDuration: number | undefined;
streaming: boolean | undefined;
}

async function createFunctionFolder({
Expand All @@ -360,7 +353,6 @@ async function createFunctionFolder({
includeFiles,
excludeFiles,
maxDuration,
streaming,
}: CreateFunctionFolderArgs) {
const functionFolder = new URL(`./functions/${functionName}.func/`, config.outDir);

Expand Down Expand Up @@ -389,7 +381,7 @@ async function createFunctionFolder({
handler,
launcherType: 'Nodejs',
maxDuration,
supportsResponseStreaming: streaming,
supportsResponseStreaming: true,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ import vercel from '@astrojs/vercel/serverless';

export default defineConfig({
output: "server",
adapter: vercel({
streaming: true
})
adapter: vercel()
});

0 comments on commit d23967a

Please sign in to comment.