Skip to content

Zain Fathoni's personal website built using Remix and deployed at Deno Deploy

Notifications You must be signed in to change notification settings

zainfathoni/website

Repository files navigation

Remix + Deno

Welcome to the Deno template for Remix! 🦕

For more, check out the Remix docs.

Install

npx create-remix@latest --template deno

Managing dependencies

Read about how we recommend to manage dependencies for Remix projects using Deno.

  • ✅ You should use npm to install NPM packages

    npm install react
    import { useState } from "react";
  • ✅ You may use inlined URL imports or deps.ts for Deno modules.

    import { copy } from "https://deno.land/std@0.138.0/streams/conversion.ts";
  • ❌ Do not use import maps.

Development

From your terminal:

npm run dev

This starts your app in development mode, rebuilding assets on file changes.

Type hints

This template provides type hinting to VS Code via a dedicated import map.

To get types in another editor, use an extension for Deno that supports import maps and point your editor to ./.vscode/resolve_npm_imports.json.

It resolve NPM imports for packages/remix-deno. This import map is used solely for the denoland.vscode-deno extension. Remix does not support import maps.Dependency management is done through npm and node_modules/ instead. "Deno-only dependencies may be imported via URL imports (without using import maps). @remix-run/deno code is already a Deno module, so just get types for it directly from node_modules/.

For more, see our decision doc for interop between Deno and NPM.

Production

First, build your app for production:

npm run build

Then run the app in production mode:

npm start

Deployment

Building the Deno app (npm run build) results in two outputs:

  • build/ (server bundle)
  • public/build/ (browser bundle)

You can deploy these bundles to any host that runs Deno, but here we'll focus on deploying to Deno Deploy.

Setting up Deno Deploy

  1. Sign up for Deno Deploy.

  2. Create a new Deno Deploy project for this app.

  3. Replace <your deno deploy project> in the deploy script in package.json with your Deno Deploy project name:

    {
      "scripts": {
        "deploy": "deployctl deploy --project=<your deno deploy project> --include=.cache,build,public ./build/index.js"
      }
    }
  4. Create a personal access token for the Deno Deploy API and export it as DENO_DEPLOY_TOKEN:

    export DENO_DEPLOY_TOKEN=<your Deno Deploy API token>

    You may want to add this to your rc file (e.g. .bashrc or .zshrc) to make it available for new terminal sessions, but make sure you don't commit this token into git. If you want to use this token in GitHub Actions, set it as a GitHub secret.

  5. Install the Deno Deploy CLI, deployctl:

    deno install --allow-read --allow-write --allow-env --allow-net --allow-run --no-check -r -f https://deno.land/x/deploy/deployctl.ts
  6. If you have previously installed the Deno Deploy CLI, you should update it to the latest version:

    deployctl upgrade

Deploying to Deno Deploy

After you've set up Deno Deploy, run:

npm run deploy

About

Zain Fathoni's personal website built using Remix and deployed at Deno Deploy

Topics

Resources

Stars

Watchers

Forks