Gatsby: How to create a fully static web app

Created on 27 Mar 2020  路  3Comments  路  Source: gatsbyjs/gatsby

Summary

Relevant information


I created a simple app in Gatsby that's just a simple table that displays information in rows and a modify button that allows me to edit it. onClick, the modify button pops up a modal view where I can input text, etc. All of this works well when served with a web server, but when I do gatsby build and access the generated static folder, the modify button doesn't do anything when clicked. When inspected, there's no onClick on the element. Are there any settings or workaround to make it work? My project only allows for straight HTML no server.

image

Like why wouldn't the browser just resolve these paths??

Environment (if relevant)

Binaries:
    Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
    Yarn: 1.21.1 - /usr/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
  Languages:
    Python: 2.7.17 - /usr/bin/python
  Browsers:
    Chrome: 80.0.3987.116
    Firefox: 74.0
  npmPackages:
    gatsby: ^2.19.45 => 2.19.45
    gatsby-image: ^2.2.44 => 2.2.44
    gatsby-plugin-manifest: ^2.3.3 => 2.3.3
    gatsby-plugin-offline: ^3.0.41 => 3.0.41
    gatsby-plugin-react-helmet: ^3.1.24 => 3.1.24
    gatsby-plugin-sharp: ^2.5.3 => 2.5.3
    gatsby-source-filesystem: ^2.1.56 => 2.1.56
    gatsby-transformer-sharp: ^2.4.2 => 2.4.2
  npmGlobalPackages:
    gatsby-cli: 2.11.2

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: removed
gatsby-browser.js: removed
gatsby-ssr.js: removed

question or discussion

Most helpful comment

I'm not sure exactly what you're asking for? You can use gatsby serve to serve the site such that you have interactive content.

My project only allows for straight HTML no server.

When you say "straight HTML" what do you mean? If you want only HTML, don't use gatsby just write the HTML 馃槃

All 3 comments

I'm not sure exactly what you're asking for? You can use gatsby serve to serve the site such that you have interactive content.

My project only allows for straight HTML no server.

When you say "straight HTML" what do you mean? If you want only HTML, don't use gatsby just write the HTML 馃槃

I think @herecydev is right on this one.

Sure, you might have built the site with gatsby build, but you also have to serve it with gatsby serve.

As for the dynamic behavior you are describing, see if this helps:

if (typeof window !== "undefined") {
   // your logic goes here
}

Thank you for opening this!

We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kalinchernev picture kalinchernev  路  3Comments

andykais picture andykais  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

signalwerk picture signalwerk  路  3Comments

ferMartz picture ferMartz  路  3Comments