astro/packages/integrations/deno
Matthew Phillips ae9ac5cbdc
Fixes using React.lazy and Suspense (#3160)
* Revert "Revert "Fixes using React.lazy and Suspense""

This reverts commit e621c2f7d3.

* Adds a changeset

* Fix ts errors

* Remove netlify metadata folder
2022-04-21 12:10:06 -04:00
..
src Fixes using React.lazy and Suspense (#3160) 2022-04-21 12:10:06 -04:00
test Fixes using React.lazy and Suspense (#3160) 2022-04-21 12:10:06 -04:00
CHANGELOG.md [ci] release (#3120) 2022-04-19 11:30:34 -04:00
package.json [ci] release (#3120) 2022-04-19 11:30:34 -04:00
readme.md Deno adapter (#2934) 2022-03-30 08:42:19 -04:00
tsconfig.json Deno adapter (#2934) 2022-03-30 08:42:19 -04:00

@astrojs/deno

A server-side rendering adapter for use with Deno targets. Write your code in Astro/Node and deploy to Deno servers.

In your astro.config.mjs use:

import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';

export default defineConfig({
  adapter: deno()
});

After performing a build there will be a dist/server/entry.mjs module. You can start a server simply by importing this module:

import './dist/entry.mjs';

API

Adapter options

This adapter automatically starts a server when it is imported. You can configure this through options:

import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';

export default defineConfig({
  adapter: deno({
    start: false
  })
});

If disabling start you need to write your own web server and use handle to render requests:

import { serve } from "https://deno.land/std@0.132.0/http/server.ts";
import { handle } from './dist/entry.mjs';

serve((req: Request) => {
  // Check the request, maybe do static file handling here.

  return handle(req);
});

You an also pass in a port/hostname to use:

import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';

export default defineConfig({
  adapter: deno({
    port: 8081,
    hostname: 'myhost'
  })
});